From 33d5fa38efcc82efb610c5017401e2ce48a822aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Feb 2016 13:29:37 +0100 Subject: [PATCH 1/3] Fix pdfBuildThirdpartyName must return main name. Alias should be an option. --- htdocs/core/lib/pdf.lib.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 62a92f4d5ac..34ff6103f11 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -340,22 +340,21 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) /** * Returns the name of the thirdparty * - * @param Societe|Contact $thirdparty Contact or thirdparty - * @param Translate $outputlangs Output language + * @param Societe|Contact $thirdparty Contact or thirdparty + * @param Translate $outputlangs Output language + * @param int $includealias 1=Include alias name after name * @return string */ -function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs) +function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0) { - //Recipient name + // Recipient name $socname = ''; - // On peut utiliser le nom de la societe du contact if ($thirdparty instanceof Societe) { - if (!empty($thirdparty->name_alias)) { - $socname = $thirdparty->name_alias."\n"; - } - $socname .= $thirdparty->name; + if ($includealias && !empty($thirdparty->name_alias)) { + $socname .= "\n".$thirdparty->name_alias; + } } elseif ($thirdparty instanceof Contact) { $socname = $thirdparty->socname; } else { From 4b89b0b7aa2f013db6647b24b898742f6a670291 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Feb 2016 22:12:38 +0100 Subject: [PATCH 2/3] Fix bad status translation for shipment --- htdocs/commande/class/commande.class.php | 16 ++++++++-------- htdocs/commande/list.php | 12 +++++++----- htdocs/langs/en_US/orders.lang | 1 + 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 53c914f7a3c..915e8a1e08c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2927,7 +2927,7 @@ class Commande extends CommonOrder if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 1) { @@ -2937,7 +2937,7 @@ class Commande extends CommonOrder if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 2) { @@ -2947,7 +2947,7 @@ class Commande extends CommonOrder if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); } elseif ($mode == 3) { @@ -2957,7 +2957,7 @@ class Commande extends CommonOrder if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6'); } elseif ($mode == 4) { @@ -2966,8 +2966,8 @@ class Commande extends CommonOrder if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill').$billedtext,'statut6').' '.$langs->trans('StatusOrderToBill').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered'); } elseif ($mode == 5) { @@ -2976,8 +2976,8 @@ class Commande extends CommonOrder if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1'); if ($statut==self::STATUS_ACCEPTED) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut7'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').$billedtext.' '.img_picto($langs->trans('StatusOrderToBill').$billedtext,'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').' '.img_picto($langs->trans('StatusOrderProcessed'),'statut6'); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6'); + if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6'); } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4f4fa01105d..fda90bf4056 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -162,10 +162,6 @@ if ($viewstatut <> '') { if ($viewstatut == 1 && empty($conf->expedition->enabled)) $sql.= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' else $sql.= ' AND c.fk_statut = '.$viewstatut; // brouillon, validee, en cours, annulee - if ($viewstatut == 3) - { - $sql.= ' AND c.facture = 0'; // need to create invoice - } } if ($viewstatut == 4) { @@ -372,7 +368,13 @@ if ($resql) print ''; print ''; print ''; - $liststatus=array('0'=>$langs->trans("StatusOrderDraftShort"), '1'=>$langs->trans("StatusOrderValidated"), '2'=>$langs->trans("StatusOrderSentShort"), '3'=>$langs->trans("StatusOrderDelivered"), '-1'=>$langs->trans("StatusOrderCanceledShort")); + $liststatus=array( + '0'=>$langs->trans("StatusOrderDraftShort"), + '1'=>$langs->trans("StatusOrderValidated"), + '2'=>$langs->trans("StatusOrderSentShort"), + '3'=>$langs->trans("StatusOrderDelivered"), + '-1'=>$langs->trans("StatusOrderCanceledShort") + ); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); print ''; print ''; diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 72044348151..d7105badd32 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -32,6 +32,7 @@ StatusOrderSent=Shipment in process StatusOrderOnProcessShort=Ordered StatusOrderProcessedShort=Processed StatusOrderDelivered=Delivered +StatusOrderDeliveredShort=Delivered StatusOrderToBillShort=Delivered StatusOrderToBill2Short=To bill StatusOrderApprovedShort=Approved From 773e5e3b0aca0a2da089c15284b9d519e150c504 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Feb 2016 01:00:13 +0100 Subject: [PATCH 3/3] Fix: specific contact of object were lost when used to create invoice. --- htdocs/compta/facture.php | 55 ++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 090a82cbaa2..d922ce35d96 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -942,7 +942,15 @@ if (empty($reshook)) if ($id > 0) { - // If deposit invoice + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines or deposit lines"); + $result = $srcobject->fetch($object->origin_id); + + // If deposit invoice if ($_POST['type'] == Facture::TYPE_DEPOSIT) { $typeamount = GETPOST('typedeposit', 'alpha'); @@ -956,13 +964,6 @@ if (empty($reshook)) { $amountdeposit = 0; - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); - $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $totalamount = 0; @@ -1012,14 +1013,6 @@ if (empty($reshook)) } else { - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $lines = $srcobject->lines; @@ -1124,12 +1117,38 @@ if (empty($reshook)) $error ++; } } + + // Now we create same links to contact than the ones found on origin object + if (empty($conf->global->INVOICE_NO_PROPAGATE_CONTACTS_FROM_ORIGIN)) + { + $originforcontact = $object->origin; + $originidforcontact = $object->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + $originforcontact=$srcobject->origin; + $originidforcontact=$srcobject->origin_id; + } + $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + + $resqlcontact = $db->query($sqlcontact); + if ($resqlcontact) + { + while($objcontact = $db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n"; + $object->add_contact($objcontact->fk_socpeople, $objcontact->code); + } + } + else dol_print_error($resqlcontact); + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; } - } // If some invoice's lines already known - else { + } + else + { // If some invoice's lines coming from page $id = $object->create($user); for($i = 1; $i <= $NBLINES; $i ++) {