* Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/comm/propal.php \ingroup propale \brief Page liste des propales (vision commercial) */ require("./pre.inc.php"); $user->getrights('propale'); if (!$user->rights->propale->lire) accessforbidden(); $langs->load('companies'); $langs->load('propal'); $langs->load('compta'); $langs->load('bills'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); require_once('./propal_model_pdf.class.php'); require_once('../propal.class.php'); require_once('../actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); // Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } $year=isset($_GET["year"])?$_GET["year"]:""; $month=isset($_GET["month"])?$_GET["month"]:""; // Nombre de ligne pour choix de produit/service prédéfinis $NBLINES=4; $form=new Form($db); /******************************************************************************/ /* Actions */ /******************************************************************************/ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') { if ($user->rights->propale->supprimer) { $propal = new Propal($db, 0, $_GET['propalid']); $propal->delete($user); $propalid = 0; $brouillon = 1; } Header('Location: propal.php'); } if ($_POST['action'] == 'add') { $propal = new Propal($db, $_GET['socidp']); $propal->datep = mktime(12, 1 , 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $propal->duree_validite = $_POST['duree_validite']; $propal->contactid = $_POST['contactidp']; $propal->projetidp = $_POST['projetidp']; $propal->modelpdf = $_POST['modelpdf']; $propal->author = $user->id; $propal->note = $_POST['note']; $propal->ref = $_POST['ref']; for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++) { $xid = 'idprod'.$i; $xqty = 'qty'.$i; $xremise = 'remise'.$i; $propal->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); } $id = $propal->create(); /* * Generation */ if ($id) { propale_pdf_create($db, $id, $_POST['modelpdf']); Header ('Location: propal.php?propalid='.$id); } } if ($_GET['action'] == 'pdf') { $propal = new Propal($db); $propal->fetch($_GET['propalid']); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer) { /* * Cloture de la propale */ $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->cloture($user, $_POST['statut'], $_POST['note']); } /* * Envoi de la propale par mail * */ if ($_POST['action'] == 'send') { $langs->load('mails'); $propal= new Propal($db); if ( $propal->fetch($_POST['propalid']) ) { $propalref = sanitize_string($propal->ref); $file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf'; if (is_readable($file)) { $soc = new Societe($db, $propal->socidp); if ($_POST['sendto']) { // Le destinataire a été fourni via le champ libre $sendto = $_POST['sendto']; $sendtoid = 0; } elseif ($_POST['receiver']) { // Le destinataire a été fourni via la liste déroulante $sendto = $soc->contact_get_email($_POST['receiver']); $sendtoid = $_POST['receiver']; } if (strlen($sendto)) { $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $message = $_POST['message']; if ($_POST['action'] == 'send') { $subject = $langs->trans('Propal').' '.$propal->ref; $actiontypeid=3; $actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.
'; if ($message) { $actionmsg.='Texte utilisé dans le corps du message:
'; $actionmsg.=$message; } $actionmsg2='Envoi Propal par mail'; } $filepath[0] = $file; $filename[0] = $propal->ref.'.pdf'; $mimetype[0] = 'application/pdf'; if ($_FILES['addedfile']['tmp_name']) { $filepath[1] = $_FILES['addedfile']['tmp_name']; $filename[1] = $_FILES['addedfile']['name']; $mimetype[1] = $_FILES['addedfile']['type']; } // Envoi de la facture $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc); if ($mailfile->sendfile()) { $msg='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; // Insertion action include_once('../contact.class.php'); $actioncomm = new ActionComm($db); $actioncomm->type_id = $actiontypeid; $actioncomm->label = $actionmsg2; $actioncomm->note = $actionmsg; $actioncomm->date = time(); // L'action est faite maintenant $actioncomm->percent = 100; $actioncomm->contact = new Contact($db,$sendtoid); $actioncomm->societe = new Societe($db,$propal->socidp); $actioncomm->user = $user; // User qui a fait l'action $actioncomm->propalrowid = $propal->id; $ret=$actioncomm->add($user); // User qui saisi l'action if ($ret < 0) { dolibarr_print_error($db); } else { // Renvoie sur la fiche Header('Location: propal.php?propalid='.$propal->id.'&msg='.urlencode($msg)); exit; } } else { $msg='
'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'
'; } } else { $msg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; dolibarr_syslog('Le mail du destinataire est vide'); } } else { dolibarr_syslog('Impossible de lire :'.$file); } } else { dolibarr_syslog('Impossible de lire les données de la propale. Le fichier propal n\'a peut-être pas été généré.'); } } if ($_GET['action'] == 'commande') { /* * Cloture de la propale */ $propal = new Propal($db); $propal->fetch($propalid); $propal->create_commande($user); } if ($_GET['action'] == 'modif' && $user->rights->propale->creer) { /* * Repasse la propale en mode brouillon */ $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->reopen($user->id); } if ($_POST['action'] == "addligne" && $user->rights->propale->creer) { /* * Ajout d'une ligne produit dans la propale */ $propal = new Propal($db); $ret=$propal->fetch($_POST['propalid']); if (isset($_POST['np_tva_tx'])) { $propal->insert_product_generic( $_POST['np_desc'], $_POST['np_price'], $_POST['np_qty'], $_POST['np_tva_tx'], $_POST['np_remise']); } else { $propal->insert_product( $_POST['idprod'], $_POST['qty'], $_POST['remise'], $_POST['np_desc']); } propale_pdf_create($db, $_POST['propalid'], $propal->modelpdf); } if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer) { /* * Mise à jour d'une ligne dans la propale */ $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->UpdateLigne($_POST['ligne'], $_POST['subprice'], $_POST['qty'], $_POST['remise']); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } if ($_POST['action'] == 'setpdfmodel' && $user->rights->propale->creer) { $propal = new Propal($db, 0, $_GET['propalid']); $propal->set_pdf_model($user, $_POST['modelpdf']); propale_pdf_create($db, $_GET['propalid'], $_POST['modelpdf']); } if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer) { /* * Supprime une ligne produit dans la propale */ $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->delete_product($_GET['ligne']); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } if ($_GET['valid'] == 1 && $user->rights->propale->valider) { $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->update_price($_GET['propalid']); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); $propal->valid($user); } if ($_POST['action'] == 'setremise' && $user->rights->propale->creer) { $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->set_remise($user, $_POST['remise']); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } if ($_POST['action'] == 'set_project') { $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->set_project($user, $_POST['projetidp']); } if ($_POST['action'] == 'set_contact') { $propal = new Propal($db); $propal->fetch($_GET['propalid']); $propal->set_contact($user, $_POST['contactidp']); } llxHeader(); /* * Affichage fiche propal en mode visu * */ if ($_GET['propalid'] > 0) { if ($msg) print "$msg
"; $html = new Form($db); $propal = new Propal($db); $propal->fetch($_GET['propalid']); $societe = new Societe($db); $societe->fetch($propal->soc_id); $h=0; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('CommercialCard'); $hselected=$h; $h++; $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('AccountancyCard'); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; $head[$h][1] = $langs->trans("Preview"); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Info'); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Documents'); $h++; dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); /* * Confirmation de la suppression de la propale * */ if ($_GET['action'] == 'delete') { $html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); print '
'; } /* * Fiche propal * */ $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,'; $sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x'; $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id; if ($socidp) $sql .= ' AND s.idp = '.$socidp; $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql)) { $obj = $db->fetch_object($resql); $societe = new Societe($db); $societe->fetch($obj->idp); print ''; $rowspan=6; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Destinataire $langs->load('mails'); print ''; print ''; $dests=$societe->contact_array($societe->id); $numdest = count($dests); if ($numdest==0) { print ''; } else { if ($propal->statut == 0 && $user->rights->propale->creer) { print ''; } else { if (!empty($propal->contactid)) { print ''; } else { print ''; } } } print ''; if ($conf->projet->enabled) $rowspan++; print ''; if ($conf->projet->enabled) { $langs->load("projects"); print ''; $numprojet = $societe->has_projects(); if (! $numprojet) { print ''; } else { if ($propal->statut == 0 && $user->rights->propale->creer) { print ''; } else { if (!empty($propal->projetidp)) { print ''; } else { print ''; } } } print ''; } print ''; if ($propal->brouillon == 1 && $user->rights->propale->creer) { print ''; print ''; print ''; print ''; } else { print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Statut print ''; print '
'.$langs->trans('Company').''; if ($societe->client == 1) { $url ='fiche.php?socid='.$societe->id; } else { $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; } print ''.$societe->nom.'Conditions de réglement'.' '.'
'.$langs->trans('Date').''; print dolibarr_print_date($propal->date,'%a %d %B %Y'); print ''.$langs->trans('DateEndPropal').''; if ($propal->fin_validite) { print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); } else { print $langs->trans("Unknown"); } print '
'.$langs->trans('MailTo').''; print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale
'; print ''.$langs->trans('AddContact').''; print '
'; print '
'; print ''; $form->select_contacts($societe->id, $propal->contactid, 'contactidp'); print '
'; print ''; print ''; print ''; require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); $contact=new Contact($db); $contact->fetch($propal->contactid); print ''; print $contact->firstname.' '.$contact->name; print ''; print ' '.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Project').''; print $langs->trans("NoProject").''; print 'id.'&action=create>'.$langs->trans('AddProject').''; print ''; print '
'; print ''; $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); print '
'; print ''; print ''; print ''; $proj = new Project($db); $proj->fetch($propal->projetidp); print ''; print $proj->title; print ''; print ' 
'.$langs->trans('GlobalDiscount').'
% '; print ''; print ''; print ' ?'; print ''.$propal->remise_percent.'%
'.$langs->trans('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('VAT').''.price($propal->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; if ($propal->brouillon == 1 && $user->rights->propale->creer) { print ''; } /* * Lignes de propale * */ $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,'; $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_propal = '.$propal->id; $sql.= ' ORDER BY pt.rowid ASC'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; print ''; if ($num) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; } $var=true; while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; // Update ligne de propale if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) { print ''; if ($objp->fk_product > 0) { print ''; } else { print '\n"; } print ''; print '\n"; print ''; if ($objp->remise_percent > 0) { print '\n"; } else { print ''; } print '\n"; // Icone d'edition et suppression if ($propal->statut == 0 && $user->rights->propale->creer) { print ''; print ''; } else { print ''; } print ''; } // Update ligne de propal if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] == 'editline' && $_GET["ligne"] == $objp->rowid) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } $total = $total + ($objp->qty * $objp->price); $i++; } $db->free($resql); } else { dolibarr_print_error($db); } /* * Ajouter une ligne */ if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; // Ajout produit produits/services personalisés print ''; print ''; print ''; $var=true; print '\n"; print ' '; print ' \n"; print ' '; print ' '; print ' '; print ' '; print ''; print ''; // Ajout de produits/services prédéfinis print ''; print ''; print ''; $var=!$var; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; } print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); else print img_object($langs->trans('ShowProduct'),'product'); print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); if ($objp->date_start && $objp->date_end) { print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; } if ($objp->date_start && ! $objp->date_end) { print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; } if (! $objp->date_start && $objp->date_end) { print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; } print ($objp->description && $objp->description!=$obj->product)?'
'.$objp->description:''; print '
'.stripslashes(nl2br($objp->description)); if ($objp->date_start && $objp->date_end) { print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; } if ($objp->date_start && ! $objp->date_end) { print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; } if (! $objp->date_start && $objp->date_end) { print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; } print "'.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; print img_edit(); print ''; print img_delete(); print '  
  %
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').'   
'; print $html->select_tva('np_tva_tx', $conf->defaulttx) . "%
'; $html->select_produits('','idprod','',20); print '
'; print ''; print '
 %
'; } } else { dolibarr_print_error($db); } print ''; /* * Formulaire cloture (signé ou non) */ if ($_GET['action'] == 'statut') { print '
'; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Note').'
'.$langs->trans("CloseAs").''; print ''; print ''; print '
'; } /* * Boutons Actions */ print '
'; // Valid if ($propal->statut == 0) { if ($user->rights->propale->valider) { print ''.$langs->trans('Valid').''; } } // Save if ($propal->statut == 1) { if ($user->rights->propale->creer) { print ''.$langs->trans('Edit').''; } } // Build PDF if ($user->rights->propale->creer) { if ($propal->statut < 2) { print ''.$langs->trans("BuildPDF").''; } else { print ''.$langs->trans("RebuildPDF").''; } } // Send if ($propal->statut == 1) { if ($user->rights->propale->envoyer) { $propref = sanitize_string($obj->ref); $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; if (file_exists($file)) { print ''.$langs->trans('Send').''; } } } // Close if ($propal->statut != 0) { if ($propal->statut == 1 && $user->rights->propale->cloturer) { print ''.$langs->trans('Close').''; } } // Delete if ($propal->statut == 0) { if ($user->rights->propale->supprimer) { print ''.$langs->trans('Delete').''; } } print '
'; print '
'; /* * Documents */ if ($propal->brouillon == 1) { print '
'; print ''; } print_titre($langs->trans('Documents')); print ''; $propref = sanitize_string($propal->ref); $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; $relativepath = $propref.'/'.$propref.'.pdf'; $var=true; if (file_exists($file)) { print ''; print ''; print ''; print ''; } if ($propal->brouillon == 1 && $user->rights->propale->creer) { print ''; } print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
Modèle'; $html = new Form($db); $modelpdf = new Propal_Model_pdf($db); $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); print ''; print '
\n"; if ($propal->brouillon == 1) { print '
'; } /* * Commandes rattachées */ if($conf->commande->enabled) { $coms = $propal->associated_orders(); if (sizeof($coms) > 0) { print '
'; print_titre($langs->trans('RelatedOrders')); print ''; print ''; print ''; print ''; print ''; print ''; $var=true; for ($i = 0 ; $i < sizeof($coms) ; $i++) { $var=!$var; print '\n"; print ''; print ''; print "\n"; } print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'; print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date).''.$coms[$i]->total_ttc.'
'; } } print '
'; /* * Liste des actions propres à la propal */ $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { print_titre($langs->trans('ActionsOnPropal')); $i = 0; $total = 0; $var=true; print ''; print ''; print "\n"; while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; print ''; print ''; print '\n"; print ''; $authoract = new User($db); $authoract->id = $objp->fk_user_author; $authoract->fetch(''); print ''; print "\n"; $i++; } print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; } } else { dolibarr_print_error($db); } print '
'; /* * Action presend * */ if ($_GET['action'] == 'presend') { print '
'; print_titre($langs->trans('SendPropalByMail')); $liste[0]=" "; foreach ($societe->contact_email_array() as $key=>$value) { $liste[$key]=$value; } // Créé l'objet formulaire mail include_once('../html.formmail.class.php'); $formmail = new FormMail($db); $formmail->fromname = $user->fullname; $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=$liste; $formmail->withcc=1; $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); $formmail->withfile=1; $formmail->withbody=1; // Tableau des substitutions $formmail->substit['__PROPREF__']=$propal->ref; // Tableau des paramètres complémentaires $formmail->param['action']='send'; $formmail->param['models']='propal_send'; $formmail->param['propalid']=$propal->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; $formmail->show_form(); } } else { /**************************************************************************** * * * Mode Liste des propales * * * ****************************************************************************/ $sortorder=$_GET['sortorder']; $sortfield=$_GET['sortfield']; $page=$_GET['page']; $viewstatut=$_GET['viewstatut']; if (! $sortfield) $sortfield='p.datep'; if (! $sortorder) $sortorder='DESC'; $limit = $conf->liste_limit; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; $sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; $sql.= ' WHERE p.fk_soc = s.idp'; if (!empty($_GET['search_ref'])) { $sql .= " AND p.ref LIKE '%".$_GET['search_ref']."%'"; } if (!empty($_GET['search_societe'])) { $sql .= " AND s.nom LIKE '%".$_GET['search_societe']."%'"; } if (!empty($_GET['search_montant_ht'])) { $sql .= " AND p.price='".$_GET['search_montant_ht']."'"; } if ($_GET['socidp']) { $sql .= ' AND s.idp = '.$_GET['socidp']; } if ($_GET['viewstatut'] <> '') { $sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')'; } if ($month > 0) { $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; } if ($year > 0) { $sql .= " AND date_format(p.datep, '%Y') = $year"; } if (strlen($_POST['sf_ref']) > 0) { $sql .= " AND p.ref like '%".$_POST["sf_ref"] . "%'"; } $sql .= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; $sql .= $db->plimit($limit + 1,$offset); $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); print_barre_liste($langs->trans('ListOfProposals'), $page,'propal.php','&socidp='.$socidp,$sortfield,$sortorder,'',$num); $i = 0; print ''; print ''; print_liste_field_titre($langs->trans('Ref'),'propal.php','p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield); print_liste_field_titre($langs->trans('Company'),'propal.php','s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield); print_liste_field_titre($langs->trans('Date'),'propal.php','p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield); print_liste_field_titre($langs->trans('DateEndPropalShort'),'propal.php','dfv','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield); print_liste_field_titre($langs->trans('Price'),'propal.php','p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="right"',$sortfield); print_liste_field_titre($langs->trans('Status'),'propal.php','p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'align="center"',$sortfield); print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; $var=true; while ($i < min($num,$limit)) { $objp = $db->fetch_object($result); $now = time(); $var=!$var; print ''; print '\n"; if ($objp->client == 1) { $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp; } else { $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->idp; } print ''; // Date propale print '\n"; // Date fin validite if ( $now > $objp->dfv && $objp->dfv > 0 ) { print ''; } else { print ''; } print '\n"; $propal=New Propal($db); print '\n"; print "\n"; $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; $i++; } print '
'; print ''; print ''; print ''; print ' '; print ''; print ''; print '
'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''; $y = strftime('%Y',$objp->dp); $m = strftime('%m',$objp->dp); print strftime('%d',$objp->dp)."\n"; print ' '; print dolibarr_print_date($objp->dp,'%b')."\n"; print ' '; print strftime('%Y',$objp->dp)."'.dolibarr_print_date($objp->dfv); if ($objp->fk_statut == 1 && $objp->dfv < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ' '.price($objp->price)."'.$propal->LibStatut($objp->fk_statut,0)."
'; $db->free($result); } else { dolibarr_print_error($db); } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>