From a16e2ef2855cd1fff0d31d4f501cc930edc5190a Mon Sep 17 00:00:00 2001 From: marc_ocebo Date: Mon, 27 Jun 2005 21:47:44 +0000 Subject: [PATCH] =?UTF-8?q?L'onglet=20'Documents'=20des=20propales=20est?= =?UTF-8?q?=20fonctionnel=20+=20diverses=20modifications=20esth=E9tiques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 1881 ++++++++++++++++-------------- htdocs/comm/propal/document.php | 236 ++-- htdocs/comm/propal/info.php | 68 +- htdocs/comm/propal/note.php | 172 ++- htdocs/html.form.class.php | 45 + htdocs/langs/en_US/projects.lang | 3 +- htdocs/langs/en_US/propal.lang | 7 +- htdocs/langs/fr_FR/projects.lang | 1 + htdocs/langs/fr_FR/propal.lang | 7 +- htdocs/project.class.php | 26 + htdocs/projet/fiche.php | 9 +- htdocs/propal.class.php | 65 +- htdocs/societe.class.php | 26 +- 13 files changed, 1420 insertions(+), 1126 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a3c477debd4..be824cc90e0 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,7 +1,8 @@ - * Copyright (C) 2004-2005 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * 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 @@ -28,31 +29,31 @@ \brief Page liste des propales */ -require("./pre.inc.php"); +require('./pre.inc.php'); -$langs->load("companies"); -$langs->load("propal"); -$langs->load("bills"); +$langs->load('companies'); +$langs->load('propal'); +$langs->load('bills'); $user->getrights('propale'); if (!$user->rights->propale->lire) - accessforbidden(); + accessforbidden(); -if ($conf->projet->enabled) require_once "../project.class.php"; -if($conf->commande->enabled) require_once "../commande/commande.class.php"; -require("./propal_model_pdf.class.php"); -require("../propal.class.php"); -require("../actioncomm.class.php"); -require(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); +if ($conf->projet->enabled) require_once '../project.class.php'; +if($conf->commande->enabled) require_once '../commande/commande.class.php'; +require('./propal_model_pdf.class.php'); +require('../propal.class.php'); +require('../actioncomm.class.php'); +require(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); /* * Sécurité accés client */ if ($user->societe_id > 0) { - $action = ''; - $socidp = $user->societe_id; + $action = ''; + $socidp = $user->societe_id; } if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } @@ -62,293 +63,295 @@ if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } // 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 ($_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 ($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') +if ($_POST['action'] == 'add') { - $propal = new Propal($db, $_GET["socidp"]); + $propal = new Propal($db, $_GET['socidp']); + $propal->datep = mktime(12, 1 , 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $propal->datep = mktime(12, 1 , 1, - $_POST["remonth"], - $_POST["reday"], - $_POST["reyear"]); + $propal->duree_validite = $_POST['duree_validite']; - $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->contactid = $_POST["contactidp"]; - $propal->projetidp = $_POST["projetidp"]; - $propal->modelpdf = $_POST["modelpdf"]; - $propal->author = $user->id; - $propal->note = $_POST["note"]; + $propal->ref = $_POST['ref']; - $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]); + } - for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++) - { - $xid = "idprod".$i; - $xqty = "qty".$i; - $xremise = "remise".$i; + $id = $propal->create(); - $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"); - } + /* + * Generation + */ + if ($id) + { + propale_pdf_create($db, $id, $_POST['modelpdf']); + Header ('Location: propal.php?propalid='.$id); + } } -if ($_GET["action"] == 'pdf') +if ($_GET['action'] == 'pdf') { - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); - propale_pdf_create($db, $_GET["propalid"], $propal->modelpdf); + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } -if ($_POST["action"] == 'setstatut' && $user->rights->propale->cloturer) +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"]); -} + /* + * 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') + * Envoi de la propale par mail + * + */ +if ($_POST['action'] == 'send') { - $langs->load("mails"); + $langs->load('mails'); + $propal= new Propal($db); + if ( $propal->fetch($_POST['propalid']) ) + { + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propalref = str_replace($forbidden_chars,'_',$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']; + } - $propal= new Propal($db); - if ( $propal->fetch($_POST["propalid"]) ) - { - $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); - $propalref = str_replace($forbidden_chars,"_",$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"; - $actioncode=3; - $actionmsg ="Mail envoyé par $from à $sendto.
"; - if ($message) { - $actionmsg.="Texte utilisé dans le corps du message:
"; - $actionmsg.="$message"; - } - $actionmsg2="Envoi Propal par mail"; - } - /* - if ($_POST["action"] == 'relance') { - $subject = "Relance facture $propal->ref"; - $actioncode=10; - $actionmsg="Mail envoyé par $from à $sendto.
"; - if ($message) { - $actionmsg.="Texte utilisé dans le corps du message:
"; - $actionmsg.="$message"; - } - $actionmsg2="Relance Facture par mail"; - } - */ - $filepath[0] = $file; - $filename[0] = $propal->ref.".pdf"; - $mimetype[0] = "application/pdf"; - $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_code = $actioncode; - $actioncomm->label = $actionmsg2; - $actioncomm->note = $actionmsg; - $actioncomm->date = $db->idate(time()); - $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).' !
'; - } - } - 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 (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; + $actioncode=3; + $actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.
'; + if ($message) + { + $actionmsg.='Texte utilisé dans le corps du message:
'; + $actionmsg.=$message; + } + $actionmsg2='Envoi Propal par mail'; + } + /* + if ($_POST["action"] == 'relance') + { + $subject = "Relance facture $propal->ref"; + $actioncode=10; + $actionmsg="Mail envoyé par $from à $sendto.
"; + if ($message) + { + $actionmsg.="Texte utilisé dans le corps du message:
"; + $actionmsg.=$message; + } + $actionmsg2="Relance Facture par mail"; + } + */ + $filepath[0] = $file; + $filename[0] = $propal->ref.'.pdf'; + $mimetype[0] = 'application/pdf'; + $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_code = $actioncode; + $actioncomm->label = $actionmsg2; + $actioncomm->note = $actionmsg; + $actioncomm->date = $db->idate(time()); + $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).' !
'; + } + } + 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') +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); - + /* + * Cloture de la propale + */ + $propal = new Propal($db); + $propal->fetch($propalid); + $propal->create_commande($user); } -if ($_POST["addligne"] == $langs->trans("Add") && $user->rights->propale->creer) +if ($_GET['action'] == 'modif' && $user->rights->propale->creer) { - /* - * Ajout d'une ligne produit dans la propale - */ - if ($_POST["idprod"]) - { - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); - $propal->insert_product($_POST["idprod"], $_POST["qty"], $_POST["remise"]); - propale_pdf_create($db, $_GET["propalid"], $propal->modelpdf); - } -} - -if ($_POST["addproduct"] == $langs->trans("Add") && $user->rights->propale->creer) -{ - /* - * Ajout d'une ligne produit dans la propale - */ - if (strlen($_POST["np_desc"]) && strlen($_POST["np_price"])) - { - - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); - - $propal->insert_product_generic($_POST["np_desc"], - $_POST["np_price"], - $_POST["np_qty"], - $_POST["np_tva_tx"], - $_POST["np_remise"]); - } + /* + * Repasse la propale en mode brouillon + */ + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $propal->reopen($user->id); } -if ($_POST["action"] == 'setremise' && $user->rights->propale->creer) +if ($_POST['addligne'] == $langs->trans('Add') && $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"] == '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); + /* + * Ajout d'une ligne produit dans la propale + */ + if ($_POST['idprod']) + { + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $propal->insert_product($_POST['idprod'], $_POST['qty'], $_POST['remise']); + propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); + } } -if ($_GET["valid"] == 1 && $user->rights->propale->valider) +if ($_POST['addproduct'] == $langs->trans('Add') && $user->rights->propale->creer) { - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); - $propal->update_price($_GET["propalid"]); - propale_pdf_create($db, $_GET["propalid"], $propal->modelpdf); - $propal->valid($user); + /* + * Ajout d'une ligne produit dans la propale + */ + if (strlen($_POST['np_desc']) && strlen($_POST['np_price'])) + { + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $propal->insert_product_generic( + $_POST['np_desc'], + $_POST['np_price'], + $_POST['np_qty'], + $_POST['np_tva_tx'], + $_POST['np_remise']); + } +} + +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'] == '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'] == '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(); @@ -358,684 +361,770 @@ llxHeader(); * Affichage fiche propal en mode visu * */ -if ($_GET["propalid"]) +if ($_GET['propalid']) { - if ($msg) print "$msg
"; + if ($msg) print "$msg
"; + $html = new Form($db); - $html = new Form($db); + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); + $societe = new Societe($db); + $societe->fetch($propal->soc_id); + $h=0; - $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('Card'); + $hselected=$h; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Card"); - $hselected=$h; - $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/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/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"); + 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,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.note, 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."c_propalst as c, ".MAIN_DB_PREFIX."socpeople as x"; - $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = $propal->id"; - - if ($socidp) - { - $sql .= " AND s.idp = $socidp"; - } - - $result = $db->query($sql); - if ( $result ) - { - - if ($db->num_rows($result)) + /* + * Confirmation de la suppression de la propale + * + */ + if ($_GET['action'] == 'delete') { - - $obj = $db->fetch_object($result); - - $soc = new Societe($db); - $soc->fetch($obj->idp); - - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - /* la form est ouverte avant la table pour respect des normes */ - print '
'; - print ''; - } - - print ""; - $rowspan=7; - - print ''; - print ''; - - print ''; - - print ''; - - $langs->load("mails"); - print ""; - - if ($conf->projet->enabled && $propal->projet_id) $rowspan++; - - print '"; - - if ($conf->projet->enabled && $propal->projet_id) - { - $langs->load("projects"); - - $projet = new Project($db); - $projet->fetch($propal->projet_id); - print ''; - } - - $author = new User($db, $obj->fk_user_author); - $author->fetch(''); - print ""; - - print ''; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - print ''; - print ''; - } - else - { - print ''; - } - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - 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").''.strftime("%A %d %B %Y",$propal->date); - if ($propal->fin_validite) - { - print " (".strftime("%d %B %Y",$propal->fin_validite).")"; - } - print ' 
".$langs->trans("MailTo")."$obj->firstname $obj->name".($obj->email?" <$obj->email>":"")."'.$langs->trans("Note").' :
'. nl2br($propal->note)."
'.$langs->trans("Projects").''; - print ''; - print $projet->title.'
".$langs->trans("Author")."$author->fullname
'.$langs->trans("GlobalDiscount").'% '; - print ''; - print ' ?'; - print ''.$propal->remise_percent.' %
'.$langs->trans("AmountHT").''.price($obj->price).''.$conf->monnaie.'
'.$langs->trans("VAT").''.price($propal->total_tva).''.$conf->monnaie.'
'.$langs->trans("AmountTTC").''.price($propal->total_ttc).''.$conf->monnaie.'
'.$langs->trans("Status").''.$propal->getLibStatut().'

"; - - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ""; - } + $html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); + print '
'; + } - if ($_GET["action"] == 'statut') - { - print "
id\" method=\"post\">"; - print '
'; - print ''; - print "
Clôturer comme : '; - print "'; - print '
'.$langs->trans("Comments").' :
"; - } + /* + * Fiche propal + * + */ + $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note, 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.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x'; + $sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id; - /* - * Lignes de propale - * - */ - $sql = "SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt 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"; - $result = $db->query($sql); - if ($result) - { - $num_lignes = $db->num_rows($result); - $i = 0; $total = 0; + if ($socidp) + { + $sql .= ' AND s.idp = '.$socidp; + } - print ''; - if ($num_lignes) - { - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=True; - while ($i < $num_lignes) + $result = $db->query($sql); + if ( $result ) + { + if ($db->num_rows($result)) { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } + $obj = $db->fetch_object($result); - 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 facture - // \todo - - - $total = $total + ($objp->qty * $objp->price); - $i++; - } - - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - /* - * Ajouter une ligne - * - */ - if ($propal->statut == 0 && $user->rights->propale->creer) - { - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - print ''; - print ''; - - // Ajout produit produits/services personalisés - $var=true; - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print ""; - - // Ajout de produits/services prédéfinis - $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 ' '.stripslashes(nl2br($objp->description?$objp->description:$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 '".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) . "remise_client."\" name=\"np_remise\"> %trans("Add")."\" name=\"addproduct\">
"; - $html->select_produits('','idprod','',20); - print "  %

\n"; - - } - - /* - * Fin Ajout ligne - * - */ - print ''; - - - - /* - * Barre d'actions - */ - if ($propal->statut < 2) - { - print '
'; - - // Valid - if ($propal->statut == 0) - { - if ($user->rights->propale->valider) - { - print "id&valid=1\">".$langs->trans("Valid").""; - } - - } - - // Save - if ($propal->statut == 1) - { - if ($user->rights->propale->creer) - { - print "id&action=modif\">".$langs->trans("Edit").""; - } - } - - // Build PDF - if ($propal->statut < 2 && $user->rights->propale->creer) - { - print ''.$langs->trans("BuildPDF").''; - } - - // Send - if ($propal->statut == 1) - { - if ($user->rights->propale->envoyer) + $societe = new Societe($db); + $societe->fetch($obj->idp); + // \todo faire en sorte que la form respecte à nouveau la norme + // problème : sans javascript, ça va être chaud... + print ''; + $rowspan=7; + print ''; + print ''; + print ''; + print ''; + $langs->load('mails'); + print ''; + print ''; + print ''; + + if ($conf->projet->enabled && $propal->projetidp) + $rowspan++; + + print ''; + + print ''; + + $author = new User($db, $obj->fk_user_author); + $author->fetch(''); + print ''; + + print ''; + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Company').''; + if ($societe->client == 1) { - $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); - $propref = str_replace($forbidden_chars,"_",$obj->ref); - $file = $conf->propal->dir_output . "/$propref/$propref.pdf"; - if (file_exists($file)) - { - print "id&action=presend\">".$langs->trans("Send").""; - } - } + $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); + if ($propal->fin_validite) + { + print ' ('.dolibarr_print_date($propal->fin_validite).')'; + } + print ' 
'.$langs->trans('MailTo').''; + + $dests=$societe->contact_array($societe->id); + $numdest = count($dests); + if ($numdest==0) + { + print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale
'; + print ''.$langs->trans('AddContact').''; + } + else + { + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print '
'; + print ''; + $form->select_contacts($societe->id, $propal->contactid, 'contactidp'); + print ''; + print '
'; + } + else + { + if (!empty($propal->contactid)) + { + require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); + $contact=new Contact($db); + $contact->fetch($propal->contactid); + print ''; + print $contact->firstname.' '.$contact->name; + print ''; + if ($contact->email) + { + print ' <'.$contact->email.'>'; + } + } + } + } + print '
'.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Projects').''; + if ($conf->projet->enabled) + { + $langs->load('projects'); + $numprojet = $societe->has_projects(); + if (!$numprojet) + { + print 'Cette société n\'a pas de projet.
'; + print 'id.'&action=create>'.$langs->trans('AddProject').''; + } + else + { + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print '
'; + print ''; + $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); + print ''; + print '
'; + } + else + { + if (!empty($propal->projetidp)) + { + $proj = new Project($db); + $proj->fetch($propal->projetidp); + print ''; + print $proj->title; + print ''; + } + } + } + } + print '
'.$langs->trans('Author').''.$author->fullname.'
'.$langs->trans('GlobalDiscount').'
% '; + print ''; + print ' ?'; + print ''.$propal->remise_percent.' %
'.$langs->trans('AmountHT').''.price($obj->price).''.$conf->monnaie.'
'.$langs->trans('VAT').''.price($propal->total_tva).''.$conf->monnaie.'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).''.$conf->monnaie.'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + } + + if ($_GET['action'] == 'statut') + { + print '
'; + print '
'; + print ''; + print '
Clôturer comme : '; + print ''; + print '
'.$langs->trans('Comments').' :
'; + } + + /* + * Lignes de propale + * + */ + $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt 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'; + $result = $db->query($sql); + if ($result) + { + $num_lignes = $db->num_rows($result); + $i = 0; + $total = 0; + + print ''; + if ($num_lignes) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=True; + while ($i < $num_lignes) + { + $objp = $db->fetch_object($result); + $var=!$var; + 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 facture + // \todo + + + $total = $total + ($objp->qty * $objp->price); + $i++; + } + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + + /* + * Ajouter une ligne + * + */ + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + print ''; + print ''; + + // Ajout produit produits/services personalisés + $var=true; + print '\n"; + print ' '; + print ' \n"; + print ' '; + print ' '; + print ' '; + print ' '; + print ''; + + // Ajout de produits/services prédéfinis + $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 ' '.stripslashes(nl2br($objp->description?$objp->description:$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 ''.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 '  %

'; + } + /* + * Fin Ajout ligne + * + */ + print '
'; + + + /* + * Barre d'actions + */ + if ($propal->statut < 2) + { + 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 ($propal->statut < 2 && $user->rights->propale->creer) + { + print ''.$langs->trans('BuildPDF').''; + } + + // Send + if ($propal->statut == 1) + { + if ($user->rights->propale->envoyer) + { + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars,'_',$obj->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + if (file_exists($file)) + { + print ''.$langs->trans('Send').''; + } + } + } + + // Delete + if ($propal->statut == 0) + { + if ($user->rights->propale->supprimer) + { + print ''.$langs->trans('Delete').''; + } + } + + // Close + if ($propal->statut != 0) + { + if ($propal->statut == 1 && $user->rights->propale->cloturer) + { + print ''.$langs->trans('Close').''; + } + } + print '

'; } - // Delete - if ($propal->statut == 0) + + + /* + * + */ + if ($propal->brouillon == 1) { - if ($user->rights->propale->supprimer) - { - print "id&action=delete\">".$langs->trans("Delete").""; - } + print '
'; + print ''; + } + print '
'; + print_titre(''.$langs->trans('Document').''); + + + /* + * + */ + print ''; + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars,'_',$propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + $relativepath = $propref.'/'.$propref.'.pdf'; + + $var=true; + + if (file_exists($file)) + { + print ''; + print ''; + print ''; + print ''; } - // Close - if ($propal->statut != 0) + if ($propal->brouillon == 1 && $user->rights->propale->creer) { - if ($propal->statut == 1 && $user->rights->propale->cloturer) - { - print "id&action=statut\">".$langs->trans("Close").""; - } - } - - print "
"; - - } - - - /* - * - */ - if ($propal->brouillon == 1) - { - print ''; - print ''; - } - print '
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
'; } - } - else - { - dolibarr_print_error($db); - } + print "
'; - print_titre(''.$langs->trans("Document").''); - - - /* - * - */ - - print ''; - - $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); - $propref = str_replace($forbidden_chars,"_",$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"; - - /* - * Si le module commandes est activé ... - */ - if($conf->commande->enabled) { - $nb_commande = sizeof($propal->commande_liste_array()); - if ($nb_commande > 0) - { - $coms = $propal->associated_orders(); - print '
'; - - print "\n"; - - for ($i = 0 ; $i < $nb_commande ; $i++) - { - print '\n"; - print "\n"; - } - - print "
Commande(s) rattachée(s)
'.$coms[$i]->ref."
"; - } - } - - 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 "; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - if ($num) - { - print_titre($langs->trans("ActionsOnPropal")); - - $i = 0; $total = 0; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $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.'
"; + print '
Modèle'; + $html = new Form($db); + $modelpdf = new Propal_Model_pdf($db); + $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); + print ''; + print '
\n"; - print "
"; + /* + * Si le module commandes est activé ... + */ + if($conf->commande->enabled) + { + $nb_commande = sizeof($propal->commande_liste_array()); + if ($nb_commande > 0) + { + $coms = $propal->associated_orders(); + print '
'; + print ''; + for ($i = 0 ; $i < $nb_commande ; $i++) + { + print '\n"; + print "\n"; + } + print '
Commande(s) rattachée(s)
'.$coms[$i]->ref."
'; + } + } + print ''; - if ($propal->brouillon == 1) - { - 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 ; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans('ActionsOnPropal')); + $i = 0; + $total = 0; + print ''; + print ''; + print "\n"; - /* - * - * - */ - if ($_GET["action"] == 'presend') - { + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $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 ''; + + if ($propal->brouillon == 1) + { + print ''; + } + + /* + * + * + */ + if ($_GET['action'] == 'presend') + { print '
'; - print_titre($langs->trans("SendPropalByMail")); + print_titre($langs->trans('SendPropalByMail')); $liste[0]=" "; - foreach ($soc->contact_email_array() as $key=>$value) { + 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; + // 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 - { - dolibarr_print_error($db); - } + $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 + { + dolibarr_print_error($db); + } } else { - /**************************************************************************** - * * - * Mode Liste des propales * - * * - ****************************************************************************/ + /**************************************************************************** + * * + * Mode Liste des propales * + * * + ****************************************************************************/ - $sortorder=$_GET["sortorder"]; - $sortfield=$_GET["sortfield"]; - $page=$_GET["page"]; - $viewstatut=$_GET["viewstatut"]; + $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; + 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,".$db->pdate("p.datep")." as dp,".$db->pdate("p.fin_validite")." as dfv, c.label as statut, c.id as statutid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; + $sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref,'.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv, c.label as statut, c.id as statutid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c'; + $sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id'; - if ($_GET["socidp"]) - { - $sql .= " AND s.idp = ".$_GET["socidp"]; - } - - if ($_GET["viewstatut"] <> '') - { - $sql .= " AND c.id = ".$_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"; - $sql .= $db->plimit($limit + 1,$offset); - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - 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",'width="15%"',$sortfield); - print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","","&socidp=$socidp&viewstatut=$viewstatut",'width="30%"',$sortfield); - print_liste_field_titre($langs->trans("Date"),"propal.php","p.datep","","&socidp=$socidp&viewstatut=$viewstatut", 'width="25%" align="right" colspan="2"',$sortfield); - print_liste_field_titre($langs->trans("Price"),"propal.php","p.price","","&socidp=$socidp&viewstatut=$viewstatut", ' width="20%" align="right"',$sortfield); - print_liste_field_titre($langs->trans("Status"),"propal.php","p.fk_statut","","&socidp=$socidp&viewstatut=$viewstatut",'width="10%" align="center"',$sortfield); - print "\n"; - $var=true; - - while ($i < min($num,$limit)) + if (!empty($_GET['search_ref'])) { - $objp = $db->fetch_object(); - $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 ''; - - if ( $now > $objp->dfv && $objp->dfv > 0 ) - { - print ""; - } - else - { - print ""; - } - - print "\n"; - - print "\n"; - print "\n"; - print "\n"; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - - $i++; + $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 c.id = '.$_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 '
'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'".strftime("%d %b %Y",$objp->dfv)." "; - $y = strftime("%Y",$objp->dp); - $m = strftime("%m",$objp->dp); - - print strftime("%d",$objp->dp)."\n"; - print " "; - print strftime("%B",$objp->dp)."\n"; - print " "; - print strftime("%Y",$objp->dp)."".price($objp->price)."$objp->statut
'; + print ''; + print_liste_field_titre($langs->trans('Ref'),'propal.php','p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'width="15%"',$sortfield); + print_liste_field_titre($langs->trans('Company'),'propal.php','s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'width="30%"',$sortfield); + print_liste_field_titre($langs->trans('Date'),'propal.php','p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'width="25%" align="right" colspan="2"',$sortfield); + print_liste_field_titre($langs->trans('Price'),'propal.php','p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, ' width="20%" align="right"',$sortfield); + print_liste_field_titre($langs->trans('Status'),'propal.php','p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'width="10%" 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 ''; + + if ( $now > $objp->dfv && $objp->dfv > 0 ) + { + print ''; + } + else + { + print ''; + } + + print '\n"; + + print '\n"; + print '\n"; + print "\n"; + + $total = $total + $objp->price; + $subtotal = $subtotal + $objp->price; + + $i++; + } + print '
'; + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; + print ''; + print '
'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''.strftime('%d %b %Y',$objp->dfv).' '; + $y = strftime('%Y',$objp->dp); + $m = strftime('%m',$objp->dp); + + print strftime('%d',$objp->dp)."\n"; + print ' '; + print strftime('%B',$objp->dp)."\n"; + print ' '; + print strftime('%Y',$objp->dp)."'.price($objp->price)."'.$objp->statut."
'; + $db->free($result); + } + else + { + dolibarr_print_error($db); } - - print ""; - $db->free(); - } - else - { - dolibarr_print_error($db); - } } $db->close(); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 8f675dd216a..16077fba1ea 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2005 Laurent Destailleur +/* Copyright (C) 2003-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2005 Laurent Destailleur + * 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 @@ -20,140 +21,167 @@ * $Source$ */ -/** \file htdocs/comm/propal/document.php - \ingroup propale - \brief Page de gestion des documents attachées à une proposition commerciale - \version $Revision$ +/** + \file htdocs/comm/propal/document.php + \ingroup propale + \brief Page de gestion des documents attachées à une proposition commerciale + \version $Revision$ */ -require("./pre.inc.php"); -require_once("../../propal.class.php"); +require('./pre.inc.php'); +require_once('../../propal.class.php'); $user->getrights('propale'); if (!$user->rights->propale->lire) - accessforbidden(); + accessforbidden(); llxHeader(); +$propalid=empty($_GET['propalid']) ? 0 : intVal($_GET['propalid']); +$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; function do_upload ($upload_dir) { - global $local_file, $error_msg; + global $local_file, $error_msg, $langs; - if (! is_dir($upload_dir)) - { - umask(0); - mkdir($upload_dir, 0755); - } - - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) - { - print "Le fichier est valide, et a été téléchargé avec succès.\n"; - //print_r($_FILES); - } - else - { - echo "Le fichier n'a pas été téléchargé"; - // print_r($_FILES); - } + if (! is_dir($upload_dir)) + { + umask(0); + mkdir($upload_dir, 0755); + } + if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) + { + echo $langs->trans('FileUploaded'); + } + else + { + echo $langs->trans('FileNotUploaded'); + } } +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ - -if ($_GET["id"] > 0) +if ($propalid > 0) { - $propal = new Propal($db); - - if ($propal->fetch($_GET["id"])) + $propal = new Propal($db); + + if ($propal->fetch($propalid)) { - - $upload_dir = $conf->propal->dir_output . "/" . $propal->ref ; - - if ( $error_msg ) - { - echo "$error_msg

"; - } - - if ($action=='delete') - { - $file = $upload_dir . "/" . urldecode($urlfile); - dol_delete_file($file); - } - - if ( $_POST["sendit"] ) - { - do_upload ($upload_dir); - } - - - print ''; - - print ""; - print "
Documents associés à la proposition : ".$propal->ref_url."
"; - - print '
'; - print ''; - print '
'; - print ''; - print '
'; - print '

'; - - clearstatcache(); - - $handle=opendir($upload_dir); - - if ($handle) - { - print ''; - - while (($file = readdir($handle))!==false) - { - if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - print '\n"; - - print ''; - print ''; - - print '\n"; + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars, '_', $propal->ref); + $upload_dir = $conf->propal->dir_output.'/'.$propref; + if ( $error_msg ) + { + echo ''.$error_msg.'

'; } - } - print "
'; - echo ''.$file.''; - print "'.filesize($upload_dir."/".$file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($upload_dir."/".$file)).''; - if ($file == $propal->ref . '.pdf') - { - echo '-'; - } - else - { - echo ''.$langs->trans("Delete").''; - } - print "
"; +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + if ($action=='delete') + { + $file = $upload_dir . '/' . urldecode($_GET['urlfile']); + dol_delete_file($file); + } - closedir($handle); + if ( $_POST['sendit'] ) + { + do_upload ($upload_dir); + } + + $h=0; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Card'); + $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'); + $hselected=$h; + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); + + print_titre($langs->trans('AssociatedDocuments').' '.$propal->ref_url); + + print '
'; + print ''; + print '
'; + print ''; + print '
'; + print '

'; + + clearstatcache(); + + $handle=opendir($upload_dir); + + if ($handle) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + while (($file = readdir($handle))!==false) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $var=!$var; + print ''; + print '\n"; + print ''; + print ''; + print '\n"; + } + } + print '
'.$langs->trans('Document').''.$langs->trans('Size').''.$langs->trans('Date').' 
'; + echo ''.$file.''; + print "'.filesize($upload_dir.'/'.$file). ' bytes'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).''; + if ($file == $propref . '.pdf') + { + echo '-'; + } + else + { + echo ''.$langs->trans('Delete').''; + } + print "
'; + print '
'; + closedir($handle); + } + else + { + print '

'.$langs->trans('ErrorCantOpenDir').' '.$upload_dir.''; + } } - else + else { - print "

Impossible d'ouvrir : ".$upload_dir.""; + dolibarr_print_error($db); } - } - else - { - dolibarr_print_error($db); - } } else { - print "Erreur"; + print 'Erreur'; } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('Dernière modification $Date$ révision $Revision$'); ?> diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 383559f85be..3af8b831958 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -27,55 +27,59 @@ \version $Revision$ */ -require("./pre.inc.php"); +require('./pre.inc.php'); -$langs->load("propal"); +$langs->load('propal'); $user->getrights('propale'); if (!$user->rights->propale->lire) - accessforbidden(); + accessforbidden(); -require("../../propal.class.php"); +require('../../propal.class.php'); /* * * */ llxHeader(); -if ($_GET["propalid"]) +if ($_GET['propalid']) { - $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("Card"); - $h++; + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Note"); - $h++; + $societe = new Societe($db); + $societe->fetch($propal->soc_id); + $h=0; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Info"); - $hselected=$h; - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref"); - - $propal->info($propal->id); + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Card'); + $h++; - print '
'; - dolibarr_print_object_info($propal); - print '
'; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Note'); + $h++; - print "
"; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Info'); + $hselected=$h; + $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); + + $propal->info($propal->id); + + print '
'; + dolibarr_print_object_info($propal); + print '
'; + + print '
'; - $db->close(); + $db->close(); } -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('Dernière modification $Date$ révision $Revision$'); ?> diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index bb786d25185..e1c18e5b346 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -23,20 +23,20 @@ */ /** - \file htdocs/comm/propal/note.php - \ingroup propale - \brief Fiche d'information sur une proposition commerciale - \version $Revision$ + \file htdocs/comm/propal/note.php + \ingroup propale + \brief Fiche d'information sur une proposition commerciale + \version $Revision$ */ -require("./pre.inc.php"); -require("../../propal.class.php"); +require('./pre.inc.php'); +require('../../propal.class.php'); -$langs->load("propal"); +$langs->load('propal'); $user->getrights('propale'); if (!$user->rights->propale->lire) - accessforbidden(); + accessforbidden(); /* @@ -44,20 +44,19 @@ if (!$user->rights->propale->lire) */ if ($user->societe_id > 0) { - unset($_GET["action"]); - $socidp = $user->societe_id; + unset($_GET['action']); + $socidp = $user->societe_id; } /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($_POST["action"] == 'update' && $user->rights->propale->creer) +if ($_POST['action'] == 'update' && $user->rights->propale->creer) { - $propal = new Propal($db); - $propal->fetch($_GET["propalid"]); - $propal->update_note($_POST["note"]); - + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $propal->update_note($_POST['note']); } llxHeader(); @@ -66,90 +65,87 @@ $html = new Form($db); /* Fin des Actions */ /******************************************************************************/ -if ($_GET["propalid"]) +if ($_GET['propalid']) { - $propal = new Propal($db); - if ( $propal->fetch($_GET["propalid"]) ) - { - - $societe = new Societe($db); - if ( $societe->fetch($propal->soc_id) ) + $propal = new Propal($db); + if ( $propal->fetch($_GET['propalid']) ) { - $h=0; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Card"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Note"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Info"); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref"); - - print ''; - - print ''; - print ''; + $societe = new Societe($db); + if ( $societe->fetch($propal->soc_id) ) + { + $h=0; - print ''; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Card'); + $h++; - print ''; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Note'); + $hselected=$h; + $h++; - print '"; - - if ($_GET["action"] == 'edit') - { - print ''; - print ''; - print '"; - print ''; - print ''; - } + $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++; - print "
'.$langs->trans("Company").''; - if ($societe->client == 1) - { - $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; - } - else - { - $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; - } - print ''.$societe->nom.''.$langs->trans("Status").''.$propal->statut_libelle.'
'.$langs->trans("Date").''.strftime("%A %d %B %Y",$propal->date); - if ($propal->fin_validite) - { - print " (".strftime("%d %B %Y",$propal->fin_validite).")"; - } - print ''.$langs->trans("Author").''; - $author = new User($db, $propal->user_author_id); - $author->fetch(''); - print $author->fullname.'
'.$langs->trans("Note").' :
'. nl2br($propal->note)."
"; - print '
'; - print ''; + dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref"); - /* - * Actions - */ + print ''; - print '
'; - - if ($user->rights->propale->creer && $_GET["action"] <> 'edit') - { - print "id&action=edit\">".$langs->trans("Edit").""; - } - - print "
"; + print ''; + print ''; + print ''; + print ''; - } + print ''; + + if ($_GET['action'] == 'edit') + { + print ''; + print ''; + print '"; + print ''; + print ''; + } + + print '
'.$langs->trans('Company').''; + if ($societe->client == 1) + { + $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; + } + else + { + $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; + } + print ''.$societe->nom.''.$langs->trans('Status').''.$propal->statut_libelle.'
'.$langs->trans('Date').''; + print dolibarr_print_date($propal->date); + if ($propal->fin_validite) + { + print ' ('.dolibarr_print_date($propal->fin_validite).')'; + } + print ''.$langs->trans('Author').''; + $author = new User($db, $propal->user_author_id); + $author->fetch(''); + print $author->fullname.'
'.$langs->trans('Note').' :
'. nl2br($propal->note).'
'; + print '
'; + print ''; + + /* + * Actions + */ + + print '

'; + if ($user->rights->propale->creer && $_GET['action'] <> 'edit') + { + print ''.$langs->trans('Edit').''; + } + print '
'; + } } - } $db->close(); llxFooter('$Date$ - $Revision: 1.15 '); diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 4e161172c25..02906c64920 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -388,6 +388,51 @@ class Form } + /** + * \brief Affiche la liste déroulante des projets d'une société donnée + * + */ + function select_projects($socid='', $selected='', $htmlname='projectid') + { + $socid=intVal($socid); + if (empty($socid)) + return; + // On recherche les societes + $sql = 'SELECT p.rowid, p.title FROM '; + $sql .= MAIN_DB_PREFIX .'projet as p'; + $sql .= ' WHERE fk_soc='.$socid; + $sql .= ' ORDER BY p.title ASC'; + + $result=$this->db->query($sql); + if ($result) + { + print ''; + } + else + { + dolibarr_print_error($this->db); + } + } + /** * \brief Retourne la liste des produits * \param selected Produit présélectionné diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index c43f795bc59..fea0638649f 100755 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -7,4 +7,5 @@ AddProject=Add project DeleteAProject=Supprimer un projet ConfirmDeleteAProject=Are you sure you want to delete this project ? LastProjects=Last %s projects -AllProjects=All projects \ No newline at end of file +AllProjects=All projects +ShowProject=Show project diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 8b0b060e190..c9ed60e05ac 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -31,4 +31,9 @@ ActionsOnPropal=Tasks on proposal NoOpenedPropals=No opened commercial proposals NoOtherOpenedPropals=No other opened commercial proposals RefProposal=Commercial proposal ref -SendPropalByMail=Send commercial proposal by mail \ No newline at end of file +SendPropalByMail=Send commercial proposal by mail +Documents=Documents +FileNotUploaded=The file was not uploaded +FileUploaded=The file was successfully uploaded +AssociatedDocuments=Documents associated with the proposal: +ErrorCantOpenDir=Can't open directory diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 21d7fc83822..518ccab2944 100755 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -8,3 +8,4 @@ DeleteAProject=Supprimer un projet ConfirmDeleteAProject=Êtes-vous sûr de vouloir supprimer ce projet ? LastProjects=Les %s derniers projets AllProjects=Tous les projets +ShowProject=Afficher projet diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 06d26eb4ddb..ab45a441860 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -31,4 +31,9 @@ ActionsOnPropal=Actions sur la proposition NoOpenedPropals=Pas de proposition ouverte NoOtherOpenedPropals=Pas d'autre proposition ouverte RefProposal=Réf proposition commerciale -SendPropalByMail=Envoi proposition commerciale par mail \ No newline at end of file +SendPropalByMail=Envoi proposition commerciale par mail +Documents=Documents +FileNotUploaded=Le fichier n'a pas été téléchargé +FileUploaded=Le fichier a été téléchargé avec succés +AssociatedDocuments=Documents associés à la proposition : +ErrorCantOpenDir=Impossible d'ouvrir le répertoire diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 8cf8b200620..e850e72d7ff 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -103,6 +103,32 @@ class Project { } } + /* + * \brief Met à jour objet projet dans la base + */ + + function update() + { + $this->ref = ereg_replace("\"","",stripslashes($this->ref)); + $this->ref = ereg_replace("'","",stripslashes($this->ref)); + $this->ref = trim($this->ref); + + $this->title = ereg_replace("\"","",stripslashes($this->title)); + $this->title = ereg_replace("'","",stripslashes($this->title)); + $this->title = trim($this->title); + + $sql = "UPDATE ".MAIN_DB_PREFIX."projet SET"; + $sql .= " ref='".$this->ref."', "; + $sql .= " title='".$this->title."' "; + $sql .= " WHERE rowid=".$this->id; + + $resql = $this->db->query($sql); + if (!$resql) + { + print $this->db->error(); + } + } + /* * * diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 996f8052449..c8d68bf21e1 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -53,6 +53,8 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer) if ($_POST["action"] == 'update' && $user->rights->projet->creer) { if (! $_POST["cancel"]) { + if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"]))) + { $projet = new Project($db); $projet->id = $_POST["id"]; $projet->ref = $_POST["ref"]; @@ -60,9 +62,14 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer) $projet->update(); $_GET["id"]=$projet->id; // On retourne sur la fiche projet - } else { + } + else + { $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet } + } else { + $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet + } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index ad3c2537a25..5673e36020a 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002-2004 Rodolphe Quiedeville * Copyright (C) 2004 Éric Seigne * Copyright (C) 2004 Laurent Destailleur + * 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 @@ -545,7 +546,69 @@ class Propal } } } - + + /* + * + * + * + */ + + function set_project($user, $project_id) + { + if ($user->rights->propale->creer) + { + //verif que le projet et la société concordent + $sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socidp.' AND p.rowid='.$project_id; + $sqlres = $this->db->query($sql); + if ($sqlres) + { + $numprojet = $this->db->num_rows($sqlres); + if ($numprojet > 0) + { + $this->projetidp=$project_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_projet = '.$project_id; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $this->db->query($sql); + } + } + else + { + dolibarr_print_error($this->db); + } + } + } + + /* + * + * + * + */ + + function set_contact($user, $contact_id) + { + if ($user->rights->propale->creer) + { + //verif que le contact et la société concordent + $sql = 'SELECT p.idp FROM '.MAIN_DB_PREFIX.'socpeople as p WHERE p.fk_soc = '.$this->socidp.' AND p.idp='.$contact_id; + $sqlres = $this->db->query($sql); + if ($sqlres) + { + $numprojet = $this->db->num_rows($sqlres); + if ($numprojet > 0) + { + $this->projetidp=$project_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_soc_contact = '.$contact_id; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $this->db->query($sql); + } + } + else + { + dolibarr_print_error($this->db); + } + } + } + /* * * diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index d0cb03b2ca3..036066bb409 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -927,7 +927,7 @@ class Societe { * \brief Renvoie la liste des contacts de cette société * \return array tableau des contacts */ - + function contact_array() { $contacts = array(); @@ -1253,6 +1253,30 @@ class Societe { return -2; } } + + /** + * \brief Indique si la société a des projets + * \return bool true si la société a des projets, false sinon + */ + function has_projects() + { + $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id; + $resql = $this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + $obj = $this->db->fetch_object(); + $count = $obj->numproj; + } + else + { + $count = 0; + print $this->db->error(); + } + $this->db->free($resql); + return ($count > 0); + } + } ?>