diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 3110be7c5d4..55cff9e817b 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * @@ -53,7 +53,7 @@ llxHeader(); print_titre($langs->trans("NewProp")); -$form=new Form($db); +$html=new Form($db); /* @@ -71,11 +71,13 @@ if ($_GET["action"] == 'create') exit; } - $obj = PROPALE_ADDON; + $obj = $conf->global->PROPALE_ADDON; $modPropale = new $obj; - $numpr = $modPropale->propale_get_num($soc); - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; + $numpr = $modPropale->getNextValue($soc); + // Si numero deja pris (ne devrait pas arriver) + // on incremente par .num+1 + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; if ( $db->query($sql) ) { $num = $db->result(0, 0); @@ -85,59 +87,95 @@ if ($_GET["action"] == 'create') $numpr .= "." . ($num + 1); } } + print "
id."\" method=\"post\">"; print ""; print ''; - print ''; + // Ref + print ''; - print ''; + // Societe + print ''; + print ''; - print ''; - print ''; + // Date facture + print ''; - print ""; + print ''; - print ''; - print ''; + // Conditions de réglement + print ''; - // Date de livraison - print ''; + // Mode de réglement + print ''; + + // Remise relative + $relative_discount=$soc->remise_client; + print ''; print ''; - - // Conditions de réglement - print ''; - - // Mode de réglement - print ''; + print ''; + + // Date de livraison + if ($conf->global->PROPAL_ADD_SHIPPING_DATE) + { + print ''; + print ''; + } + /* * Destinataire de la propale */ - print "'; - print ''; + // Projet if ($conf->projet->enabled) { - /* - * Projet associ - */ - print ''; + print ''; - } - else { - print ''; + print ''; } - print ''; - print ''; + print ''; + print '"; + + print "
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'; - print $langs->trans("Comments").'
'.$langs->trans('Company').''.$soc->nom_url; + print ''; + print '
'.$langs->trans("Company").''.$soc->nom.''; - print ''; - print '
'.$langs->trans('Date').''; + $html->select_date('','','','','',"addprop"); + print '
".$langs->trans("Date").""; - $form->select_date('','','','','',"addprop"); - print "
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans("Author").''.$user->fullname.'
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans('PaymentConditions').''; + $html->select_conditions_paiements($cond_reglement_id,'cond_reglement_id'); + print '
'.$langs->trans("DateDelivery").'
'.$langs->trans('PaymentMode').''; + $html->select_types_paiements($mode_reglement_id,'mode_reglement_id'); + print '
'.$langs->trans("CustomerRelativeDiscount").''; - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") + print ' %'; + print ''.img_info().' '; + if ($relative_discount) { - $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - $syear = date("Y", $tmpdte); - $smonth = date("m", $tmpdte); - $sday = date("d", $tmpdte); - $form->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); - } + print $langs->trans("CompanyHasRelativeDiscount",$relative_discount); + } else { - $form->select_date(-1,'liv_','','','',"addprop"); + print $langs->trans("CompanyHasNoRelativeDiscount"); } print '
'.$langs->trans('PaymentConditions').''; - $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); - print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); + + // Remise avoirs + $absolute_discount=$soc->getCurrentDiscount(); + print '
'.$langs->trans("CustomerAbsoluteDiscount").''; + print ' '.$langs->trans("Currency".$conf->monnaie); + print ''.img_info().' '; + if ($absolute_discount) + { + print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); + } + else + { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } print '
'.$langs->trans("DateDelivery").''; + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") + { + $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + $syear = date("Y", $tmpdte); + $smonth = date("m", $tmpdte); + $sday = date("d", $tmpdte); + $html->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); + } + else + { + $html->select_date(-1,'liv_','','','',"addprop"); + } + print '
".$langs->trans("Contact")."\n"; + print "
".$langs->trans("Contact")."\n"; $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$soc->id; @@ -180,36 +218,40 @@ if ($_GET["action"] == 'create') print '
'.$langs->trans("Project").''; + print '
'.$langs->trans("Project").''; - $numprojet=$form->select_projects($soc->id,0,'projetidp'); + $numprojet=$html->select_projects($soc->id,0,'projetidp'); if ($numprojet==0) { print '   id.'&action=create>'.$langs->trans("AddProject").''; } print ' 
Modèle'; + print '
'.$langs->trans("Model").''; $model=new ModelePDFPropales(); $liste=$model->liste_modeles($db); - $form->select_array("model",$liste,$conf->global->PROPALE_ADDON_PDF); + $html->select_array("model",$liste,$conf->global->PROPALE_ADDON_PDF); print "
"; + print '
'; /* * Combobox pour la fonction de copie */ - print ' Copier Propal depuis'; + print ''; + print ''; + print ''; + print ''; + print '"; - print "
'.$langs->trans("CopyPropalFrom").' '; $liste_propal = array(); $liste_propal[0] = ''; $sql ="SELECT p.rowid as id, CONCAT(p.ref, '-', s.nom) as lib"; @@ -226,43 +268,48 @@ if ($_GET["action"] == 'create') $liste_propal[$row[0]]=$row[1]; $i++; } - $form->select_array("copie_propal",$liste_propal, 0); + $html->select_array("copie_propal",$liste_propal, 0); } else { - print ''; + dolibarr_print_error($db); } - print "
"; - - print '
'; - + print ''; + + print ' '; + + print ''; + print ''.$langs->trans("CreateEmptyPropal").''; + print ''; if ($conf->produit->enabled || $conf->service->enabled) { - $titre=$langs->trans("ProductsAndServices"); - $lib=$langs->trans("Product").'/'.$langs->trans("Services"); - - print_titre($titre); + $lib=$langs->trans("ProductsAndServices"); print ''; print ''; - for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++) + for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++) { print ''; print ''; - print ''; + print ''; } print "
'.$lib.''.$langs->trans("Qty").''.$langs->trans("Discount").'
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) - $form->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level); + $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level); else - $form->select_produits('',"idprod".$i,'',$conf->produit->limit_size); + $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size); print ' %
%
"; - print '
'; } + else + { + print ' '; + } + print ''; + print ''; + print '
'; /* * Si il n'y a pas de contact pour la societe on ne permet pas la creation de propale @@ -278,5 +325,6 @@ if ($_GET["action"] == 'create') } $db->close(); + llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 3a3a17a5bcd..66d18376685 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2006 Regis Houssin @@ -118,14 +118,14 @@ if ($_POST['action'] == 'setdate_livraison') if ($_POST['action'] == 'add') { - $propal = new Propal($db, $_GET['socidp']); + $propal = new Propal($db, $_POST['socidp']); /* * Si on seléctionné une propal à copier, on réalise la copie */ - if($_POST['copie_propal']) + if($_POST['createmode']=='copy' && $_POST['copie_propal']) { - if($propal->copie_from($_POST['copie_propal']) == -1) + if($propal->load_from($_POST['copie_propal']) == -1) { //$msg = '
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; $msg = '
Impossible de copier la propal Id = ' . $_POST['copie_propal'] . '!
'; @@ -135,6 +135,7 @@ if ($_POST['action'] == 'add') $propal->duree_validite = $_POST['duree_validite']; $propal->cond_reglement_id = $_POST['cond_reglement_id']; $propal->mode_reglement_id = $_POST['mode_reglement_id']; + $propal->socidp = $_POST['socidp']; $propal->contactid = $_POST['contactidp']; $propal->projetidp = $_POST['projetidp']; $propal->modelpdf = $_POST['model']; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 116273f6a0b..0727969b0a6 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -689,7 +689,7 @@ if ($_GET['action'] == 'create') print ''; - // Reference + // Ref print ''; // Societe diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index fd1ccb7771f..92c3a5e6d10 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -260,11 +260,11 @@ if ($_GET["propalid"] > 0) $langs->load('mails'); print ''; print ''; - + if ($propal->statut == 0 && $user->rights->propale->creer) { print ''; } else diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 362bc63e0dc..71090cd1372 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -459,10 +459,10 @@ class Form function select_contacts($socid,$selected='',$htmlname='contactid') { // On recherche les societes - $sql = "SELECT s.idp, s.name, s.firstname FROM "; - $sql .= MAIN_DB_PREFIX ."socpeople as s"; - $sql .= " WHERE fk_soc=".$socid; - $sql .= " ORDER BY s.name ASC"; + $sql = "SELECT s.idp, s.name, s.firstname FROM"; + $sql.= " ".MAIN_DB_PREFIX ."socpeople as s"; + $sql.= " WHERE fk_soc=".$socid; + $sql.= " ORDER BY s.name ASC"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/includes/modules/propale/mod_propale_diamant.php b/htdocs/includes/modules/propale/mod_propale_diamant.php index 398f65f6e86..b4aa2832b3a 100644 --- a/htdocs/includes/modules/propale/mod_propale_diamant.php +++ b/htdocs/includes/modules/propale/mod_propale_diamant.php @@ -79,9 +79,10 @@ class mod_propale_diamant extends ModeleNumRefPropales /** \brief Renvoi prochaine valeur attribuée + * \param objsoc Objet société * \return string Valeur */ - function getNextValue() + function getNextValue($objsoc=0) { global $db; @@ -106,16 +107,6 @@ class mod_propale_diamant extends ModeleNumRefPropales return "PR" .$y. substr("0000".$num, strlen("0000".$num)-5,5); } - - /** \brief Renvoie la référence de propale suivante non utilisée - * \param objsoc Objet société - * \return string Texte descripif - */ - function propale_get_num($objsoc=0) - { -// return $this->propale_get_num(); - return $this->getNextValue(); - } } ?> diff --git a/htdocs/includes/modules/propale/mod_propale_emeraude.php b/htdocs/includes/modules/propale/mod_propale_emeraude.php index 007ea2127ad..1e31de55b05 100644 --- a/htdocs/includes/modules/propale/mod_propale_emeraude.php +++ b/htdocs/includes/modules/propale/mod_propale_emeraude.php @@ -73,9 +73,10 @@ class mod_propale_emeraude extends ModeleNumRefPropales /** \brief Renvoi prochaine valeur attribuée + * \param objsoc Objet société * \return string Valeur */ - function getNextValue() + function getNextValue($objsoc=0) { global $db,$conf; @@ -96,16 +97,6 @@ class mod_propale_emeraude extends ModeleNumRefPropales return "PR" . "$y" . substr("0000".$num, strlen("0000".$num)-5,5); } - - /** \brief Renvoie la référence de propale suivante non utilisée - * \param objsoc Objet société - * \return string Texte descripif - */ - function propale_get_num($objsoc=0) - { -// return $this->propale_get_num(); - return $this->getNextValue(); - } } ?> diff --git a/htdocs/includes/modules/propale/mod_propale_ivoire.php b/htdocs/includes/modules/propale/mod_propale_ivoire.php index a176efec518..3a304a387f5 100644 --- a/htdocs/includes/modules/propale/mod_propale_ivoire.php +++ b/htdocs/includes/modules/propale/mod_propale_ivoire.php @@ -58,9 +58,10 @@ class mod_propale_ivoire extends ModeleNumRefPropales /** \brief Renvoi prochaine valeur attribuée + * \param objsoc Objet société * \return string Valeur */ - function getNextValue() + function getNextValue($objsoc=0) { global $db; @@ -78,16 +79,6 @@ class mod_propale_ivoire extends ModeleNumRefPropales return "PR" . "$y" . substr("000".$num, strlen("000".$num)-4,4); } - - /** \brief Renvoie la référence de propale suivante non utilisée - * \param objsoc Objet société - * \return string Texte descripif - */ - function propale_get_num($objsoc=0) - { -// return $this->propale_get_num(); - return $this->getNextValue(); - } } ?> diff --git a/htdocs/includes/modules/propale/mod_propale_jade.php b/htdocs/includes/modules/propale/mod_propale_jade.php index 828fd5f6682..fd6335e6bfd 100644 --- a/htdocs/includes/modules/propale/mod_propale_jade.php +++ b/htdocs/includes/modules/propale/mod_propale_jade.php @@ -59,9 +59,10 @@ class mod_propale_jade extends ModeleNumRefPropales /** \brief Renvoi prochaine valeur attribuée + * \param objsoc Objet société * \return string Valeur */ - function getNextValue() + function getNextValue($objsoc=0) { global $db; @@ -79,15 +80,6 @@ class mod_propale_jade extends ModeleNumRefPropales return "PROP" . ($num+1); } - - /** \brief Renvoie la référence de propale suivante non utilisée - * \param objsoc Objet société - * \return string Texte descripif - */ - function propale_get_num($objsoc=0) - { - return $this->getNextValue(); - } } ?> diff --git a/htdocs/includes/modules/propale/mod_propale_marbre.php b/htdocs/includes/modules/propale/mod_propale_marbre.php index df58d254197..cced173625f 100644 --- a/htdocs/includes/modules/propale/mod_propale_marbre.php +++ b/htdocs/includes/modules/propale/mod_propale_marbre.php @@ -84,9 +84,10 @@ class mod_propale_marbre extends ModeleNumRefPropales } /** \brief Renvoi prochaine valeur attribuée + * \param objsoc Objet société * \return string Valeur */ - function getNextValue() + function getNextValue($objsoc=0) { global $db; @@ -126,15 +127,6 @@ class mod_propale_marbre extends ModeleNumRefPropales return "PR$yymm-$num"; } - - /** \brief Renvoie la référence de propale suivante non utilisée - * \param objsoc Objet société - * \return string Texte descripif - */ - function propale_get_num($objsoc=0) - { - return $this->getNextValue(); - } } ?> diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index f05a077a50e..7eb93173ca4 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -62,4 +62,8 @@ RelatedBill=Related invoice RelatedBills=Related invoices ErrorPropalNotFound=Propal %s not found Estimate=Estimate -OtherPropals=Other proposals \ No newline at end of file +OtherPropals=Other proposals +DateDelivery=Shipping date +SetDateLivraison=Set shipping date +CopyPropalFrom=Create commercial proposal by copying existing proposal +CreateEmptyPropal=Create empty commercial proposals vierge or from list of products/services \ No newline at end of file diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index f95bbb580eb..58b56ec6f17 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -65,3 +65,5 @@ Estimate=Devis : OtherPropals=Autres propositions DateDelivery=Date de livraison SetDateLivraison=Définir la date de livraison +CopyPropalFrom=Créer proposition/devis par recopie d'un proposition existante +CreateEmptyPropal=Créer proposition/devis vierge ou depuis liste de produits prédéfinis diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 16f13da8ca4..f60c942bcb3 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -1483,17 +1483,17 @@ class Propal } /** - * \brief Copie un objet propal dont l'id est passé en premier argument dans l'objet courant, en mémoire - * \param $src_propal_id Id de la propal à copier + * \brief Charge l'objet propal en mémoire avec propal dont l'id est passé en argument + * \param $src_propal_id Id de la propal source * \return int >0 si ok, <0 si ko * \see fetch */ - function copie_from($src_propal_id) + function load_from($src_propal_id) { $src_propal = new Propal($this->db); if($src_propal->fetch($src_propal_id) < 0) { - dolibarr_syslog("Propal::Copie_from Erreur de lecture de la propal source."); + dolibarr_syslog("Propal::load_from: Erreur de lecture de la propal source."); return -1; } $this->datep = $src_propal->datep; @@ -1527,6 +1527,7 @@ class Propal $this->lignes = $src_propal->lignes; return 1; } + /** * \brief Insert en base un objet propal complétement définie par ses données membres (resultant d'une copie par exemple). * \return int l'id du nouvel objet propal en base si ok, <0 si ko
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('MailTo').''; - $html->select_contacts($societe->id, $propal->contactid, 'none'); + $html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'none'); print '