diff --git a/dev/resources/iso-normes/Accountancy-format_Ebp_txt.pdf b/dev/resources/iso-normes/Accountancy-format_Ebp_txt.pdf new file mode 100644 index 00000000000..24e6fca05e9 Binary files /dev/null and b/dev/resources/iso-normes/Accountancy-format_Ebp_txt.pdf differ diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 92c5713880c..540c0437b08 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -651,8 +651,8 @@ if ($action == 'create') print "\n"; } - $total_debit = price2num($total_debit); - $total_credit = price2num($total_credit); + $total_debit = price2num($total_debit, 'MT'); + $total_credit = price2num($total_credit, 'MT'); if ($total_debit != $total_credit) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 52b5f1c411f..6cad9372701 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -517,14 +517,19 @@ class AccountancyExport print $line->id . $separator; print $date . $separator; print $line->code_journal . $separator; - print length_accountg($line->numero_compte) . $separator; - print substr(length_accountg($line->numero_compte),0,2) . $separator; + + if (empty($line->subledger_account)) { + print $line->numero_compte . $separator; + } else { + print $line->subledger_account . $separator; + } + //print substr(length_accountg($line->numero_compte),0,2) . $separator; print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$separator; print price2num($line->montant).$separator; print $line->sens.$separator; print $date . $separator; - print 'EUR'; + //print 'EUR'; print $end_line; } } diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index e78a8e089ed..49a4df25b2a 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -191,7 +191,7 @@ print ''."\n"; // AGENDA REMINDER EMAIL -if ($conf->global->MAIN_FEATURES_LEVEL > 0) +if ($conf->global->MAIN_FEATURES_LEVEL == 2) { print ''."\n"; print ''.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).''."\n"; @@ -208,7 +208,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) } // AGENDA REMINDER BROWSER -if ($conf->global->MAIN_FEATURES_LEVEL > 0) +if ($conf->global->MAIN_FEATURES_LEVEL == 2) { print ''."\n"; print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 2cf3c120af6..be60c4fa574 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -377,38 +377,43 @@ if ($object->id > 0) print ''; } - // Relative discounts (Discounts-Drawbacks-Rebates) - print ''; - print '
'; - print $langs->trans("CustomerRelativeDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; - print ''; + $isCustomer = ($object->client == 1 || $object->client == 3); - // Absolute discounts (Discounts-Drawbacks-Rebates) - print ''; - print ''; - print ''; + print ''; + + // Absolute discounts (Discounts-Drawbacks-Rebates) + print ''; + print ''; + print ''; } - print '
'; - print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + // Relative discounts (Discounts-Drawbacks-Rebates) + if ($isCustomer) { - print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($object->remise_percent?''.$object->remise_percent.'%':'').'
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + $amount_discount=$object->getAvailableDiscounts(); + if ($amount_discount < 0) dol_print_error($db,$object->error); + if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; + //else print $langs->trans("DiscountNone"); + print '
'; - print ''; - print ''; - $amount_discount=$object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db,$object->error); - if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; - //else print $langs->trans("DiscountNone"); - print ''; - print ''; // Max outstanding bill if ($object->client) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index be5494fbb75..ba68e3324bb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -751,7 +751,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1119,7 +1119,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 6f3287b8831..13e4f13ec3d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -106,7 +106,7 @@ if ($socid > 0) $head = societe_prepare_head($object); - $isCustomer = $object->client == 1 || $object->client == 3; + $isCustomer = ($object->client == 1 || $object->client == 3); $isSupplier = $object->fournisseur == 1; print '
'; @@ -122,7 +122,7 @@ if ($socid > 0) print '
'; - if(! $isCustomer && ! $isSupplier) { + if (! $isCustomer && ! $isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; dol_fiche_end(); @@ -136,13 +136,13 @@ if ($socid > 0) print ''; - if($isCustomer) { + if ($isCustomer) { // Customer discount print '"; } - if($isSupplier) { + if ($isSupplier) { // Supplier discount print '"; @@ -155,21 +155,28 @@ if ($socid > 0) print '
'; - if($isCustomer && ! $isSupplier) { - print ''; - } - - if(! $isCustomer && $isSupplier) { - print ''; - } + /*if (! ($isCustomer && $isSupplier)) + { + if ($isCustomer && ! $isSupplier) { + print ''; + } + if (! $isCustomer && $isSupplier) { + print ''; + } + }*/ print '
'; print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; print $langs->trans("SupplierRelativeDiscount").''.price2num($object->remise_supplier_percent)."%
'; - if($isCustomer && $isSupplier) { + if ($isCustomer || $isSupplier) + { // Discount type - print ''; - print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0b0348ee5e0..66f01399183 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -662,7 +662,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1023,7 +1023,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index db497733863..81a0f3f9156 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -638,11 +638,12 @@ else print ''; print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6568ac03eba..cc58f1e6dec 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1290,15 +1290,15 @@ if (empty($reshook)) $qualified=1; if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified) $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + if ($qualified){ + $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + $tva_tx = $lines[$i]->tva_tx; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; + } + } - if ($totalamount != 0) { - if ($numlines > 0) $numlines = $numlines-1; - $tva_tx = $lines[$numlines]->tva_tx; - if (! empty($lines[$numlines]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$numlines]->vat_src_code.')'; - $amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100; - } else { + if($totalamount == 0) { $amountdeposit[0] = 0; } } else { @@ -1309,9 +1309,10 @@ if (empty($reshook)) $amount_ttc_diff = $amountdeposit[0]; } - foreach ($amountdeposit as $tva => $amount) { + if (empty($amount)) continue; + $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); //$descline.= ' - '.$langs->trans($arraylist[$typeamount]); @@ -1320,6 +1321,7 @@ if (empty($reshook)) } elseif ($typeamount=='variable') { $descline.= ' ('. $valuedeposit.'%)'; } + $descline.= ' - '.$srcobject->ref; $result = $object->addline( $descline, @@ -1682,7 +1684,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -2089,7 +2091,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a6e979cdd10..d303e6edf21 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1605,7 +1605,7 @@ class Facture extends CommonInvoice $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); + $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fb70da42665..36c1aec55b9 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -453,7 +453,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { @@ -776,7 +776,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $objectline = new FactureLigneRec($db); if ($objectline->fetch(GETPOST('lineid'))) diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index ae95d71ca9c..f09ee172a40 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -372,161 +372,156 @@ if (! is_array($x_coll) || ! is_array($x_paye)) $subtot_coll_total_ht = 0; $subtot_coll_vat = 0; - if (is_array($x_both[$thirdparty_id]['coll']['detail'])) - { + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) { - // VAT Rate - print ""; - print ''; - print ''."\n"; + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) { - foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type=1; - } - if (!empty($fields['ddate_end'])) { - $type=1; + // VAT Rate + print ""; + print ''; + print '' . "\n"; - - print ''; - - // Ref - print ''; - - // Invoice date - print ''; - - // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; - else print ''; - - // Rate - print ''; - - // Description - print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''; } else { - $text = img_object($langs->trans('Product'),'product'); + print ''; } - if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { - if ($reg[1]=='DEPOSIT') { - $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1]=='CREDIT_NOTE') { - $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + + // Rate + print ''; + + // Description + print ''; - - // Total HT - if ($modetax != 1) - { - print ''; - } - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { + // Total HT + if ($modetax != 1) { + print ''; + } + + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + print ''; + } + + // Total collected print ''; + + // VAT + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } - // Total collected - print ''; - - // VAT - print ''; - print ''; - - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; } + // Total customers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; } - // Total customers for this vat rate - print ''; - print ''; - print ''; - if ($modetax != 1) { - print ''; - print ''; - } - print ''; - print ''; - print ''; } if (count($x_coll) == 0) // Show a total ine if nothing shown @@ -567,161 +562,153 @@ if (! is_array($x_coll) || ! is_array($x_paye)) $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - if (is_array($x_both[$thirdparty_id]['paye']['detail'])) - { - print ""; - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { - foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index=>$fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type=1; - } - if (!empty($fields['ddate_end'])) { - $type=1; + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { + print ""; + print ''; + print '' . "\n"; - - print ''; - - // Ref - print ''; - - // Invoice date - print ''; - - // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; - else print ''; - - // Company name - print ''; - - // Description - print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''; } else { - $text = img_object($langs->trans('Product'),'product'); + print ''; } - if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { - if ($reg[1]=='DEPOSIT') { - $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1]=='CREDIT_NOTE') { - $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + + // Company name + print ''; + + // Description + print ''; - - // Total HT - if ($modetax != 1) - { - print ''; - } - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { + // Total HT + if ($modetax != 1) { + print ''; + } + + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + print ''; + } + + // VAT paid print ''; + + // VAT + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } - - // VAT paid - print ''; - - // VAT - print ''; - print ''; - - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; } + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; } - // Total suppliers for this vat rate - print ''; - print ''; - print ''; - if ($modetax != 1) { - print ''; - print ''; - } - print ''; - print ''; - print ''; } if (count($x_paye) == 0) { // Show a total line if nothing shown diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5f418cb0568..b681e8147a7 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -737,7 +737,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); $objectline->array_options=$array_options; // TODO verifier price_min si fk_product et multiprix diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index dc94d57809f..2b9de7fc9e2 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -892,6 +892,7 @@ class Contrat extends CommonObject $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); + if ($resql) { $error=0; @@ -908,9 +909,8 @@ class Contrat extends CommonObject if ($result > 0) { $modCodeContract = new $module(); - - if (!empty($modCodeContract->code_auto)) { - // Mise a jour ref + if (! empty($modCodeContract->code_auto)) { + // Force the ref to a draft value if numbering module is an automatic numbering $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; if ($this->db->query($sql)) { @@ -919,9 +919,6 @@ class Contrat extends CommonObject $this->ref="(PROV".$this->id.")"; } } - } else { - $error++; - $this->error='Failed to get PROV number'; } } @@ -1389,7 +1386,7 @@ class Contrat extends CommonObject if (empty($remise_percent)) $remise_percent=0; $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); - + // Clean vat code $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) @@ -1397,7 +1394,7 @@ class Contrat extends CommonObject $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 33eeda9f4b2..f7208111d7a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -519,7 +519,7 @@ if ($massaction == 'confirm_createbills') else { // Load extrafields of order $cmd->fetch_optionals(); - + $objecttmp->socid = $cmd->socid; $objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; @@ -577,6 +577,12 @@ if ($massaction == 'confirm_createbills') for ($i=0;$i<$num;$i++) { $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + // If we build one invoice for several order, we must put the invoice of order on the line + if (! empty($createbills_onebythird)) + { + $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); + } + if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 676e76fe16a..f0fe7bf437c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4932,8 +4932,6 @@ abstract class CommonObject $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $new_array_options[$key] = $this->db->idate($this->array_options[$key]); - break; case 'datetime': // If data is a string instead of a timestamp, we convert it if (! is_int($this->array_options[$key])) { @@ -4981,8 +4979,9 @@ abstract class CommonObject $table_element = $this->table_element; if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG); + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; - dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object"; @@ -4993,6 +4992,17 @@ abstract class CommonObject if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator $sql.=",".$attributeKey; } + // We must insert a default value for fields for other entities that are mandatory to avoid not null error + if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) + { + foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + $sql.=",".$tmpkey; + } + } + } $sql .= ") VALUES (".$this->id; foreach($new_array_options as $key => $value) @@ -5011,10 +5021,23 @@ abstract class CommonObject } } } + // We must insert a default value for fields for other entities that are mandatory to avoid not null error + if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) + { + foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + if (in_array($tmpval, array('int', 'double'))) $sql.=", 0"; + else $sql.=", ''"; + } + } + } + $sql.=")"; - dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG); $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->lasterror(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 48eabbefe9e..f8ae333935e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -747,7 +747,7 @@ class ExtraFields * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required. * @return array Array of attributes keys+label for all extra fields. */ - function fetch_name_optionals_label($elementtype,$forceload=false) + function fetch_name_optionals_label($elementtype, $forceload=false) { global $conf; @@ -783,8 +783,8 @@ class ExtraFields $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE entity IN (0,".$conf->entity.")"; - if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element + //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later + if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element $sql.= " ORDER BY pos"; $resql=$this->db->query($sql); @@ -794,6 +794,16 @@ class ExtraFields { while ($tab = $this->db->fetch_object($resql)) { + if ($tab->entity != 0 && $tab->entity != $conf->entity) + { + // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value + if ($tab->fieldrequired && is_null($tab->fielddefault)) + { + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type; + } + continue; + } + // We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label'] if ($tab->type != 'separate') { @@ -1515,7 +1525,7 @@ class ExtraFields } elseif ($type == 'phone') { - $value=dol_print_phone($value, '', 0, 0, '', ' ', 1); + $value=dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'price') { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 58df0ad4e22..8f0af0a5004 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3324,7 +3324,10 @@ class Form $langs->load('bills'); $opt = ''; - $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; + $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc'; + $sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql.= ' WHERE entity IN ('.getEntity('facture').')'; + $sql.= ' AND situation_counter>=1'; $sql.= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { @@ -4517,7 +4520,7 @@ class Form $out=''; $out.= ''."\n"; - - // Product label - if ($line->fk_product > 0) // If predefined product + if(empty($reshook)) { - $product->fetch($line->fk_product); - $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch - //var_dump($product->stock_warehouse[1]); + // Show product and description + $type=$line->product_type?$line->product_type:$line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($line->date_start)) $type=1; + if (! empty($line->date_end)) $type=1; - print ''."\n"; - // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->status_batch=$line->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label); - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text,$description,3,'','',$i); + // Product label + if ($line->fk_product > 0) // If predefined product + { + $product->fetch($line->fk_product); + $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch + //var_dump($product->stock_warehouse[1]); - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print ''; - } - else - { - print "\n"; - } - - // Qty - print ''; - $qtyProdCom=$line->qty; - - // Qty already shipped - print ''; - - // Qty to ship - $quantityAsked = $line->qty; - if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $quantityToBeDelivered = 0; - } - else - { - $quantityToBeDelivered = $quantityAsked - $quantityDelivered; - } - $warehouse_id = GETPOST('entrepot_id','int'); - - $warehouseObject = null; - if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection - { - print ''; - //ship from preselected location - $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number - $deliverableQty=min($quantityToBeDelivered, $stock); - if ($deliverableQty < 0) $deliverableQty = 0; - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) + print ''; + } + else { - // Quantity to send - print ''; + print "'; - } + if (! empty($line->label)) { + $text.= ' '.$line->label.''; + print $form->textwithtooltip($text,$line->desc,3,'','',$i); + } else { + print $text.' '.nl2br($line->desc); + } - print "\n"; + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print "\n"; + } - // Show subproducts of product - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) - { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print " - "; - } - } - } + // Qty + print ''; + $qtyProdCom=$line->qty; + + // Qty already shipped + print ''; + + // Qty to ship + $quantityAsked = $line->qty; + if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $quantityToBeDelivered = 0; } else { - // Product need lot - print ''; // end line and start a new one for lot/serial - print ''; + $quantityToBeDelivered = $quantityAsked - $quantityDelivered; + } + $warehouse_id = GETPOST('entrepot_id','int'); - $staticwarehouse=new Entrepot($db); - if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - - $subj=0; - // Define nb of lines suggested for this order line - $nbofsuggested=0; - if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) + $warehouseObject = null; + if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + { + print ''; + //ship from preselected location + $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number + $deliverableQty=min($quantityToBeDelivered, $stock); + if ($deliverableQty < 0) $deliverableQty = 0; + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { - foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) - { - $nbofsuggested++; - } - } - print ''; - if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) - { - foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch + // Quantity to send + print ''; - print ''; + if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; - print ''; + // Stock + if (! empty($conf->stock->enabled)) + { print ''; + } + + print "\n"; + + // Show subproducts of product + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if(count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print " + "; + } } - $subj++; - print ''; } } else { - print ''; - print ''; + // Product need lot + print ''; // end line and start a new one for lot/serial + print ''; - print ''; - } - } - } - else - { - // ship from multiple locations - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) - { - print ''; - print ''."\n"; // end line and start a new one for each warehouse + $staticwarehouse=new Entrepot($db); + if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - print ''; - $subj=0; - // Define nb of lines suggested for this order line - $nbofsuggested=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - if ($stock_warehouse->real > 0) + $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { - $nbofsuggested++; - } - } - $tmpwarehouseObject=new Entrepot($db); - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock - { - $tmpwarehouseObject->fetch($warehouse_id); - if ($stock_warehouse->real > 0) - { - $stock = + $stock_warehouse->real; // Convert it to number - $deliverableQty = min($quantityToBeDelivered,$stock); - $deliverableQty = max(0, $deliverableQty); - // Quantity to send - print ''; - print ''; - - // Stock - if (! empty($conf->stock->enabled)) - { - print ''; - } - $quantityToBeDelivered -= $deliverableQty; - if ($quantityToBeDelivered < 0) - { - $quantityToBeDelivered = 0; - } - $subj++; - print "\n"; + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) + { + $nbofsuggested++; + } } - } - // Show subproducts of product (not recommanded) - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if (count($prods_arbo) > 0) + print ''; + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print ' - "; - print ""; - } - } - } - } - else - { - print ''; - print ''; // end line and start a new one for lot/serial - - $subj=0; - print ''; - - $tmpwarehouseObject=new Entrepot($db); - $productlotObject=new Productlot($db); - // Define nb of lines suggested for this order line - $nbofsuggested=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { - foreach ($stock_warehouse->detail_batch as $dbatch) - { - $nbofsuggested++; - } - } - } - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - $tmpwarehouseObject->fetch($warehouse_id); - if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { - foreach ($stock_warehouse->detail_batch as $dbatch) + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered,$batchStock); - if ($deliverableQty < 0) $deliverableQty = 0; - print ''; + print ''; + print ''; print ''; } } - } + else + { + print ''; + print ''; + print ''; + } + } } - if ($subj == 0) // Line not shown yet, we show it + else { - print ''; - print ''; + print ''; + print ''."\n"; // end line and start a new one for each warehouse - print ''; + print ''; + + // Stock + if (! empty($conf->stock->enabled)) + { + print ''; + } + $quantityToBeDelivered -= $deliverableQty; + if ($quantityToBeDelivered < 0) + { + $quantityToBeDelivered = 0; + } + $subj++; + print "\n"; + } + } + // Show subproducts of product (not recommanded) + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if (count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print ' + "; + print ""; + } + } + } } else { - print $langs->trans("Service"); + print ''; + print ''; // end line and start a new one for lot/serial + + $subj=0; + print ''; + + $tmpwarehouseObject=new Entrepot($db); + $productlotObject=new Productlot($db); + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { + foreach ($stock_warehouse->detail_batch as $dbatch) + { + $nbofsuggested++; + } + } + } + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + $tmpwarehouseObject->fetch($warehouse_id); + if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { + foreach ($stock_warehouse->detail_batch as $dbatch) + { + //var_dump($dbatch); + $batchStock = + $dbatch->qty; // To get a numeric + $deliverableQty = min($quantityToBeDelivered,$batchStock); + if ($deliverableQty < 0) $deliverableQty = 0; + print ''; + + print ''; + } + } + } + } - print ''; + if ($subj == 0) // Line not shown yet, we show it + { + print ''; + print ''; + + print ''; + print ''; + } + } + + + //Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines)>0) + { + $colspan=5; + $orderLineExtrafields = new Extrafields($db); + $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); + $srcLine = new OrderLine($db); + $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline + $line = new ExpeditionLigne($db); + //$line->fetch_optionals($line->id); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + print ''; + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print ''; } - } - - - //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) - { - $colspan=5; - $orderLineExtrafields = new Extrafields($db); - $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); - $srcLine = new OrderLine($db); - $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline - $line = new ExpeditionLigne($db); - //$line->fetch_optionals($line->id); - $line->array_options = array_merge($line->array_options, $srcLine->array_options); - print ''; - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); - print ''; - } + } $indiceAsked++; } @@ -1986,6 +1993,11 @@ else if ($id || $ref) print ''; } + // Other attributes + $parameters = array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print "
'.$langs->trans('DiscountType').' '; - print ' '; + print '
'.$langs->trans('DiscountType').''; + if ($isCustomer) { + print ' '; + } + if ($isSupplier) { + print ' '; + } print '
'.$langs->trans("AccountancyJournal").''; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($object->fk_accountancy_journal); - - print $accountingjournal->getNomUrl(0,1,1,'',1); + if ($object->fk_accountancy_journal > 0) { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($object->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } print '
'; - if (is_numeric($thirdparty_id)) - { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } - else - { - $tmpid = preg_replace('/userid_/','',$thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print '
'; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User") . ': ' . $user_static->getNomUrl(1); } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['drate'] . ''; - if ($fields['pid']) - { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; } - } - else - { - if ($type) { - $text = img_object($langs->trans('Service'),'service'); + if (!empty($fields['ddate_end'])) { + $type = 1; + } + + + print '
' . $fields['link'] . '' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['drate'] . ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); } else { - $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + $text = img_object($langs->trans('Product'), 'product'); } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { + $payment_static->id = $fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)'; + } + } + print ''; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $payment_static->id=$fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'],'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice*100,2).'%)'; - } - } + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT'),1); - print ''; - $temp_vat=$fields['vat']*$ratiopaymentinvoice; - print price(price2num($temp_vat,'MT'),1); - //print price($fields['vat']); - print '
' . $langs->trans("Total") . ':  ' . price(price2num($subtot_coll_total_ht, 'MT')) . '' . price(price2num($subtot_coll_vat, 'MT')) . '
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
'; - if (is_numeric($thirdparty_id)) - { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } - else - { - $tmpid = preg_replace('/userid_/','',$thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print '
'; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User") . ': ' . $user_static->getNomUrl(1); } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['company_link'] . ''; - if ($fields['pid']) - { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; } - } - else - { - if ($type) { - $text = img_object($langs->trans('Service'),'service'); + if (!empty($fields['ddate_end'])) { + $type = 1; + } + + + print '
' . $fields['link'] . '' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['company_link'] . ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); } else { - $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + $text = img_object($langs->trans('Product'), 'product'); } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { + $paymentfourn_static->id = $fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)'; + } + } + print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id=$fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } - - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { - print $langs->trans("NA"); - } - else - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'],'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice*100,2).'%)'; - } - } + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT'),1); - print ''; - $temp_vat=$fields['vat']*$ratiopaymentinvoice; - print price(price2num($temp_vat,'MT'),1); - //print price($fields['vat']); - print '
' . $langs->trans("Total") . ':  ' . price(price2num($subtot_paye_total_ht, 'MT')) . '' . price(price2num($subtot_paye_vat, 'MT')) . '
'.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
'; - print ''; // ancre pour retourner sur la ligne + print ''."\n"; + print '
'; + print ''; // ancre pour retourner sur la ligne - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; - } + // Show product and description + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->status_batch=$line->product_tobatch; + $text=$product_static->getNomUrl(1); + $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text,$description,3,'','',$i); - print '
"; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - print $form->textwithtooltip($text,$line->desc,3,'','',$i); - } else { - print $text.' '.nl2br($line->desc); - } + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; + } - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - print "
'.$line->qty; - print ''; - print ''; - $quantityDelivered = $object->expeditions[$line->id]; - print $quantityDelivered; - print ''; - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); - print ''; - print ''; - } - else print $langs->trans("NA"); - print '"; + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); - // Stock - if (! empty($conf->stock->enabled)) - { - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? - { - // Show warehouse combo list - $ent = "entl".$indiceAsked; - $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; - if ($line->fk_product > 0) - { - print ''; - print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); - if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) - { - //print $stock.' '.$quantityToBeDelivered; - if ($stock < $quantityToBeDelivered) - { - print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse - } - } - } - } - else - { - print $langs->trans("Service"); - } - print '
      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."  ".$value['stock']." ".$img."
'.$line->qty; + print ''; + print ''; + $quantityDelivered = $object->expeditions[$line->id]; + print $quantityDelivered; + print ''; + print '
'; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - //var_dump($dbatch); - $batchStock = + $dbatch->qty; // To get a numeric - $deliverableQty = min($quantityToBeDelivered,$batchStock); - print '
'; - print ''; - print ''; - - print $staticwarehouse->getNomUrl(0).' / '; - - print ''; - - $detail=''; - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
'; - print $detail; - - $quantityToBeDelivered -= $deliverableQty; - if ($quantityToBeDelivered < 0) + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? { - $quantityToBeDelivered = 0; + // Show warehouse combo list + $ent = "entl".$indiceAsked; + $idl = "idl".$indiceAsked; + $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; + if ($line->fk_product > 0) + { + print ''; + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); + if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) + { + //print $stock.' '.$quantityToBeDelivered; + if ($stock < $quantityToBeDelivered) + { + print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse + } + } + } + } + else + { + print $langs->trans("Service"); + } + print '
      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."  ".$value['stock']." ".$img."
'; - print ' '; - print '
'; - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); - print '
'; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - print ''; - print ''; - } - else print $langs->trans("NA"); - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - print $tmpwarehouseObject->getNomUrl(0).' '; - - print ''; - print '('.$stock.')'; - - } - else - { - print $langs->trans("Service"); - } - print '
'; - print "      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."  ".$value['stock']." ".$img."
'; + print '
'; print ''; print ''; - print $tmpwarehouseObject->getNomUrl(0).' / '; + print $staticwarehouse->getNomUrl(0).' / '; - print ''; print ''; - //print '|'.$line->fk_product.'|'.$dbatch->batch.'|
'; - print $langs->trans("Batch").': '; - $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); - if ($result > 0) print $productlotObject->getNomUrl(1); - else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; - print ' ('.$dbatch->qty.')'; + $detail=''; + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail.= '
'; + print $detail; + $quantityToBeDelivered -= $deliverableQty; if ($quantityToBeDelivered < 0) { $quantityToBeDelivered = 0; } - //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock); $subj++; print '
'; + print ' '; + print ''; + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); + print '
'; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + // ship from multiple locations + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { - $disabled=''; - if (! empty($conf->productbatch->enabled) && $product->hasbatch()) - { - $disabled='disabled="disabled"'; - } - print ' '; - } - else - { - print $langs->trans("NA"); - } - print '
'; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $warehouse_selected_id = GETPOST('entrepot_id','int'); - if ($warehouse_selected_id > 0) - { - $warehouseObject=new Entrepot($db); - $warehouseObject->fetch($warehouse_selected_id); - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); - } - else - { - if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); - else print ''; - } + print ''; + $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if ($stock_warehouse->real > 0) + { + $nbofsuggested++; + } + } + $tmpwarehouseObject=new Entrepot($db); + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock + { + $tmpwarehouseObject->fetch($warehouse_id); + if ($stock_warehouse->real > 0) + { + $stock = + $stock_warehouse->real; // Convert it to number + $deliverableQty = min($quantityToBeDelivered,$stock); + $deliverableQty = max(0, $deliverableQty); + // Quantity to send + print '
'; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print $tmpwarehouseObject->getNomUrl(0).' '; + + print ''; + print '('.$stock.')'; + + } + else + { + print $langs->trans("Service"); + } + print '
'; + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."  ".$value['stock']." ".$img."
'; + print ''; + print ''; + + print $tmpwarehouseObject->getNomUrl(0).' / '; + + print ''; + print ''; + + //print '|'.$line->fk_product.'|'.$dbatch->batch.'|
'; + print $langs->trans("Batch").': '; + $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); + if ($result > 0) print $productlotObject->getNomUrl(1); + else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; + print ' ('.$dbatch->qty.')'; + $quantityToBeDelivered -= $deliverableQty; + if ($quantityToBeDelivered < 0) + { + $quantityToBeDelivered = 0; + } + //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock); + $subj++; + print '
'; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $disabled=''; + if (! empty($conf->productbatch->enabled) && $product->hasbatch()) + { + $disabled='disabled="disabled"'; + } + print ' '; + } + else + { + print $langs->trans("NA"); + } + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) + { + $warehouseObject=new Entrepot($db); + $warehouseObject->fetch($warehouse_selected_id); + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); + } + else + { + if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); + else print ''; + } + } + else + { + print $langs->trans("Service"); + } + print '
"; print ''; @@ -2140,298 +2152,305 @@ else if ($id || $ref) // Loop on each product to send/sent for ($i = 0 ; $i < $num_prod ; $i++) { - print ''; // id of order line - print ''; + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - // # - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + if(empty($reshook)) { - print ''.($i+1).''; - } + print ''; // id of order line + print ''; - // Predefined product or service - if ($lines[$i]->fk_product > 0) - { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + // # + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); - $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; + print ''.($i+1).''; + } + + // Predefined product or service + if ($lines[$i]->fk_product > 0) + { + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; + } + else + $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); + + print ''; + + // Show product and description + $product_static->type=$lines[$i]->fk_product_type; + $product_static->id=$lines[$i]->fk_product; + $product_static->ref=$lines[$i]->ref; + $product_static->status_batch=$lines[$i]->product_tobatch; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); + print $form->textwithtooltip($text,$description,3,'','',$i); + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; + } + print "\n"; } else - $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); - - print ''; - - // Show product and description - $product_static->type=$lines[$i]->fk_product_type; - $product_static->id=$lines[$i]->fk_product; - $product_static->ref=$lines[$i]->ref; - $product_static->status_batch=$lines[$i]->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; - } - print "\n"; - } - else - { - print ""; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + print ""; + if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); - if (! empty($lines[$i]->label)) { - $text.= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } - - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - print "\n"; - } - - // Qty ordered - print ''.$lines[$i]->qty_asked.''; - - // Qty in other shipments (with shipment and warehouse used) - if ($origin && $origin_id > 0) - { - print ''; - foreach ($alreadysent as $key => $val) - { - if ($lines[$i]->fk_origin_line == $key) - { - $j = 0; - foreach($val as $shipmentline_id=> $shipmentline_var) - { - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" - - $j++; - if ($j > 1) print '
'; - $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) - { - $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); - } - } - } - } - print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - // edit mode - print ''; - if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) - { - print ''; - $line = new ExpeditionLigne($db); - foreach ($lines[$i]->detail_batch as $detail_batch) - { - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - if ($lines[$i]->entrepot_id == 0) - { - // only show lot numbers from src warehouse when shipping from multiple warehouses - $line->fetch($detail_batch->fk_expeditiondet); - } - print ''; - print ''; + if (! empty($lines[$i]->label)) { + $text.= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i); + } else { + print $text.' '.nl2br($lines[$i]->description); } - // add a 0 qty lot row to be able to add a lot - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - print ''; - print ''; + + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + print "\n"; } - else if (! empty($conf->stock->enabled)) + + // Qty ordered + print ''; + + // Qty in other shipments (with shipment and warehouse used) + if ($origin && $origin_id > 0) + { + print ''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) { - if ($lines[$i]->fk_product > 0) + // edit mode + print ''; - } - else - { - // Qty to ship or shipped - print ''; - - // Warehouse source - if (! empty($conf->stock->enabled)) - { - print ''; - } - - // Batch number managment - if (! empty($conf->productbatch->enabled)) - { - if (isset($lines[$i]->detail_batch)) - { - print ''; - print ''; - } else { - print ''; - } - } - } - - // Weight - print ''; - - // Volume - print ''; - - // Size - //print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - print ''; - print ''; - - // Display lines extrafields - if (! empty($rowExtrafieldsStart)) - { - print $rowExtrafieldsStart; - print $rowExtrafieldsView; - print $rowEnd; - } - } - print ""; - - // Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) { - $colspan= empty($conf->productbatch->enabled) ? 5 : 6; - $line = new ExpeditionLigne($db); - $line->fetch_optionals($lines[$i]->id); - print ''; - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + print '
' . '' . '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). '
' . '' . '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '
'.$lines[$i]->qty_asked.''; + foreach ($alreadysent as $key => $val) + { + if ($lines[$i]->fk_origin_line == $key) + { + $j = 0; + foreach($val as $shipmentline_id=> $shipmentline_var) + { + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" + + $j++; + if ($j > 1) print '
'; + $shipment_static->fetch($shipmentline_var['shipment_id']); + print $shipment_static->getNomUrl(1); + print ' - '.$shipmentline_var['qty_shipped']; + $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) + { + $warehousestatic->fetch($shipmentline_var['warehouse']); + $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); + } + } + } + } + print '
'; + if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { - if ($lines[$i]->entrepot_id > 0) + print ''; + $line = new ExpeditionLigne($db); + foreach ($lines[$i]->detail_batch as $detail_batch) { - print ''; print ''; // Qty to ship or shipped - print ''; - // Warehouse source - print ''; + print ''; // Batch number managment - print ''; + if ($lines[$i]->entrepot_id == 0) + { + // only show lot numbers from src warehouse when shipping from multiple warehouses + $line->fetch($detail_batch->fk_expeditiondet); + } + print ''; print ''; } - else if (count($lines[$i]->details_entrepot) > 1) + // add a 0 qty lot row to be able to add a lot + print ''; + // Qty to ship or shipped + print ''; + // Batch number managment + print ''; + print ''; + } + else if (! empty($conf->stock->enabled)) + { + if ($lines[$i]->fk_product > 0) { - print ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) + if ($lines[$i]->entrepot_id > 0) { + print ''; print ''; // Qty to ship or shipped - print ''; + print ''; // Warehouse source - print ''; + print ''; // Batch number managment print ''; print ''; } + else if (count($lines[$i]->details_entrepot) > 1) + { + print ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) + { + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; + } + } + else + { + print ''; + print ''; + } } else { - print ''; - print ''; + print ''; + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; } } - else - { - print ''; - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } - } - print '
' . '' . '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). '' . '' . ' - ' . $langs->trans("NA") . '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). '
' . '' . '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '
' . '' . '' . '' . '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' - ' . $langs->trans("NA") . '
' . '' . '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' - ' . $langs->trans("NA") . '
'.$langs->trans("NotEnoughStock").'
'.$langs->trans("NotEnoughStock").'
' . '' . '' . '' . '
' . '' . '' . '' . '
'.$lines[$i]->qty_shipped.''; - if ($lines[$i]->entrepot_id > 0) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } - else if (count($lines[$i]->details_entrepot) > 1) - { - $detail = ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) - { - if ($detail_entrepot->entrepot_id > 0) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($detail_entrepot->entrepot_id); - $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'
'; - } - } - print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail); - } - print '
'; - if ($lines[$i]->product_tobatch) - { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch - { - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
'; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); - } - else - { - print $langs->trans("NA"); - } - print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); - else print ' '; - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); - else print ' '; - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").''; - print '
'; - print '
'; - } - else if ($object->statut == 0) - { - // edit-delete buttons - print '
'; - print 'id . '">' . img_edit() . ''; - print ''; - print 'id . '">' . img_delete() . ''; - print '
'; } else { - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + // Qty to ship or shipped + print ''.$lines[$i]->qty_shipped.''; + + // Warehouse source + if (! empty($conf->stock->enabled)) + { + print ''; + if ($lines[$i]->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } + else if (count($lines[$i]->details_entrepot) > 1) + { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) + { + if ($detail_entrepot->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'
'; + } + } + print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail); + } + print ''; + } + + // Batch number managment + if (! empty($conf->productbatch->enabled)) + { + if (isset($lines[$i]->detail_batch)) + { + print ''; + print ''; + if ($lines[$i]->product_tobatch) + { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch + { + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail.= '
'; + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); + } + else + { + print $langs->trans("NA"); + } + print ''; + } else { + print ''; + } + } + } + + // Weight + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); + else print ' '; + print ''; + + // Volume + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); + else print ' '; + print ''; + + // Size + //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) + { + print ''; + print '
'; + print '
'; + } + else if ($object->statut == 0) + { + // edit-delete buttons + print ''; + print 'id . '">' . img_edit() . ''; + print ''; + print ''; + print 'id . '">' . img_delete() . ''; + print ''; + + // Display lines extrafields + if (! empty($rowExtrafieldsStart)) + { + print $rowExtrafieldsStart; + print $rowExtrafieldsView; + print $rowEnd; + } + } + print ""; + + // Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines)>0) { + $colspan= empty($conf->productbatch->enabled) ? 5 : 6; + $line = new ExpeditionLigne($db); + $line->fetch_optionals($lines[$i]->id); + print ''; + if ($action == 'editline' && $lines[$i]->id == $line_id) + { + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + } + else + { + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + } + print ''; } - print ''; } } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index cb058e44598..c92962357b2 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -42,6 +42,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi // Load translation files required by the page $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); +$hookmanager->initHooks(array('ordershipmentcard')); + $id=GETPOST('id','int'); // id of order $ref= GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); @@ -613,6 +615,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " cd.qty,"; $sql.= ' cd.date_start,'; $sql.= ' cd.date_end,'; + $sql.= ' cd.special_code,'; $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; @@ -648,164 +651,169 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($resql); + $parameters = array('i' => $i, 'line' => $objp, 'num' => $num); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - // Show product and description - $type=isset($objp->type)?$objp->type:$objp->product_type; - - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($objp->date_start)) $type=1; - if (! empty($objp->date_end)) $type=1; - - print ''; - - // Product label - if ($objp->fk_product > 0) + if(empty($reshook)) { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + // Show product and description + $type=isset($objp->type)?$objp->type:$objp->product_type; + + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($objp->date_start)) $type=1; + if (! empty($objp->date_end)) $type=1; + + print ''; + + // Product label + if ($objp->fk_product > 0) { - $object->fetch_thirdparty(); - - $prod = new Product($db); - $prod->id = $objp->fk_product; - $prod->entity = $objp->entity; - $prod->getMultiLangs(); - - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + $object->fetch_thirdparty(); + + $prod = new Product($db); + $prod->id = $objp->fk_product; + $prod->entity = $objp->entity; + $prod->getMultiLangs(); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + } + else + $label = (! empty($objp->label)?$objp->label:$objp->product_label); + + print ''; + print ''; // ancre pour retourner sur la ligne + + // Show product and description + $product_static->type=$type; + $product_static->id=$objp->fk_product; + $product_static->ref=$objp->ref; + $product_static->entity = $objp->entity; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; + $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); + print $form->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print ($objp->description && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + print ''; } else - $label = (! empty($objp->label)?$objp->label:$objp->product_label); - - print ''; - print ''; // ancre pour retourner sur la ligne - - // Show product and description - $product_static->type=$type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; - $product_static->entity = $objp->entity; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; - $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print ($objp->description && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + print ""; + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($objp->label)) { + $text.= ' '.$objp->label.''; + print $form->textwithtooltip($text,$objp->description,3,'','',$i); + } else { + print $text.' '.nl2br($objp->description); + } + + // Show range + print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + print "\n"; } - print ''; - } - else - { - print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + // Qty ordered + print '' . $objp->qty . ''; - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; - print $form->textwithtooltip($text,$objp->description,3,'','',$i); - } else { - print $text.' '.nl2br($objp->description); - } - - // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); - print "\n"; - } - - // Qty ordered - print '' . $objp->qty . ''; - - // Qty already shipped - $qtyProdCom=$objp->qty; - print ''; - // Nb of sending products for this line of order - $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0); - print $qtyAlreadyShipped; - print ''; - - // Qty remains to ship - print ''; - if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; - $toBeShippedTotal += $toBeShipped[$objp->fk_product]; - print $toBeShipped[$objp->fk_product]; - } - else - { - print '0 ('.$langs->trans("Service").')'; - } - print ''; - - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - $product->load_stock('warehouseopen'); - } - - if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled)) - { + // Qty already shipped + $qtyProdCom=$objp->qty; print ''; - print $product->stock_reel; - if ($product->stock_reel < $toBeShipped[$objp->fk_product]) + // Nb of sending products for this line of order + $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0); + print $qtyAlreadyShipped; + print ''; + + // Qty remains to ship + print ''; + if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print ' '.img_warning($langs->trans("StockTooLow")); + $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; + $toBeShippedTotal += $toBeShipped[$objp->fk_product]; + print $toBeShipped[$objp->fk_product]; + } + else + { + print '0 ('.$langs->trans("Service").')'; } print ''; - } - else - { - print ' '; - } - print "\n"; - // Show subproducts lines - if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS)) - { - // Set tree of subproducts in product->sousprods - $product->get_sousproduits_arbo(); - //var_dump($product->sousprods);exit; - - // Define a new tree with quantiies recalculated - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - //var_dump($prods_arbo); - if (count($prods_arbo) > 0) + if ($objp->fk_product > 0) { - foreach($prods_arbo as $key => $value) + $product = new Product($db); + $product->fetch($objp->fk_product); + $product->load_stock('warehouseopen'); + } + + if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled)) + { + print ''; + print $product->stock_reel; + if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { - $img=''; - if ($value['stock'] < $value['stock_alert']) + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ''; + } + else + { + print ' '; + } + print "\n"; + + // Show subproducts lines + if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS)) + { + // Set tree of subproducts in product->sousprods + $product->get_sousproduits_arbo(); + //var_dump($product->sousprods);exit; + + // Define a new tree with quantiies recalculated + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + //var_dump($prods_arbo); + if (count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) { - $img=img_warning($langs->trans("StockTooLow")); + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print '      -> '.$value['fullpath'].' ('.$value['nb'].')'; + print ' '.$value['nb_total'].''; + print ' '; + print ' '; + print ''.$value['stock'].' '.$img.''."\n"; } - print '      -> '.$value['fullpath'].' ('.$value['nb'].')'; - print ' '.$value['nb_total'].''; - print ' '; - print ' '; - print ''.$value['stock'].' '.$img.''."\n"; } } } - $i++; } $db->free($resql); @@ -886,7 +894,7 @@ if ($id > 0 || ! empty($ref)) print $langs->trans("WarehouseSource"); //print ''; //print ''; - print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); + print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); if (count($formproduct->cache_warehouses) <= 0) { print '   '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").''; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 13d28189e95..c91e3a28d10 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -759,6 +759,7 @@ if ($step == 3 && $datatoexport) // un formulaire en plus pour recuperer les filtres print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 15b75495c38..24aca7e9dbf 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -362,7 +362,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); $result = $object->addline( $user, @@ -509,7 +509,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $result=$object->addline( $user, @@ -622,7 +622,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $objectline->array_options = $array_options; $result = $objectline->update($user); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 4ad0b221c36..3cc217dec18 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1501,9 +1501,10 @@ class FactureFournisseur extends CommonInvoice * @param int $origin_id id origin document * @param double $pu_ht_devise Amount in currency * @param string $ref_supplier Supplier ref + * @param string $special_code Special code * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='') + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='', $special_code='') { global $langs, $mysoc, $conf; @@ -1646,30 +1647,34 @@ class FactureFournisseur extends CommonInvoice $this->line->fk_facture_fourn=$this->id; //$this->line->label=$label; // deprecated $this->line->desc=$desc; - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->ref_supplier=$ref_supplier; + $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; + + $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); + $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); + $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->fk_product=$fk_product; $this->line->product_type=$type; $this->line->remise_percent=$remise_percent; - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->date_start=$date_start; $this->line->date_end=$date_end; $this->line->ventil=$ventil; $this->line->rang=$rang; $this->line->info_bits=$info_bits; - $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva= $total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; - $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->special_code=$this->special_code; + + $this->line->special_code=((string) $special_code != '' ? $special_code : $this->special_code); $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; $this->line->origin_id=$origin_id; @@ -1837,11 +1842,11 @@ class FactureFournisseur extends CommonInvoice $line->localtax2_tx = $txlocaltax2; $line->localtax1_type = $localtaxes_type[0]; $line->localtax2_type = $localtaxes_type[2]; - $line->total_ht = $total_ht; - $line->total_tva = $total_tva; + $line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); + $line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); $line->total_localtax1 = $total_localtax1; $line->total_localtax2 = $total_localtax2; - $line->total_ttc = $total_ttc; + $line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); $line->fk_product = $idproduct; $line->product_type = $product_type; $line->info_bits = $info_bits; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9009364d4b1..41a6d030e16 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -308,7 +308,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -614,7 +614,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 761cce030f7..77fd4b1aa69 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -499,7 +499,7 @@ if ($id > 0 || ! empty($ref)) { $sql .= " WHERE l.fk_commande = " . $object->id; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND l.product_type = 0"; - $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product + $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql .= " ORDER BY p.ref, p.label"; $resql = $db->query($sql); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index d26c950d4fe..0c0a9d6583b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -482,7 +482,7 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref,"; +$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql.= " u.firstname, u.lastname, u.photo, u.login"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); @@ -988,6 +988,7 @@ if ($resql) { $projectstatic->id=$obj->project_id; $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_title; print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c6f6d560f34..a294cf3c6ad 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -927,7 +927,10 @@ if (empty($reshook)) 0, $lines[$i]->array_options, $lines[$i]->fk_unit, - $lines[$i]->id + $lines[$i]->id, + 0, + '', + $lines[$i]->special_code ); if ($result < 0) @@ -1053,7 +1056,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -1129,7 +1132,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index b53a07104c7..3e1827d6818 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -390,7 +390,7 @@ if (! $search_all) $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref"; + $sql.= " p.rowid, p.ref, p.title"; foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8a87d4903a1..57ca70dfa98 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -71,7 +71,7 @@ if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; $optioncss = GETPOST('optioncss','alpha'); -$amounts = array();array(); +$amounts = array(); $amountsresttopay=array(); $addwarning=0; @@ -251,6 +251,22 @@ if (empty($reshook)) $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } + + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $multicurrency_amounts[$key] = -$newvalue; + } + } + if (! $error) { $db->begin(); @@ -431,6 +447,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; + print ''; print ''; dol_fiche_head(null); @@ -600,14 +617,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - print ''; + print ''; - print ''; - print ''; + print ''; // Amount print ''; - if ($object->lines[$i]->fk_product > 0) - { - $product = new Product($db); - $product->fetch($object->lines[$i]->fk_product); + print ''; + if ($object->lines[$i]->fk_product > 0) { + $product = new Product($db); + $product->fetch($object->lines[$i]->fk_product); - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; + } else + $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label); + + print '\n"; } - print_date_range($objp->date_start,$objp->date_end); - print "\n"; - } + print ''; + print ''; - print ''; - print ''; + print ""; - print ""; - - //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) { - $colspan=2; - $mode = ($object->statut == 0) ? 'edit' : 'view'; - $line = new LivraisonLigne($db); - $line->fetch_optionals($object->lines[$i]->id); - if ($action = 'create_delivery') { - $srcLine = new ExpeditionLigne($db); - $expeditionLineExtrafields = new Extrafields($db); - $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->fetch_optionals($expedition->lines[$i]->id); - $line->array_options = array_merge($line->array_options, $srcLine->array_options); + //Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines) > 0) { + $colspan = 2; + $mode = ($object->statut == 0) ? 'edit' : 'view'; + $line = new LivraisonLigne($db); + $line->fetch_optionals($object->lines[$i]->id); + if ($action = 'create_delivery') { + $srcLine = new ExpeditionLigne($db); + $expeditionLineExtrafields = new Extrafields($db); + $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); + $srcLine->fetch_optionals($expedition->lines[$i]->id); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + } + print ''; + print $line->showOptionals($extrafieldsline, $mode, array('style' => $bc[$var], 'colspan' => $colspan), $i); + print ''; } - print ''; - print $line->showOptionals($extrafieldsline, $mode, array('style'=>$bc[$var], 'colspan'=>$colspan),$i); - print ''; } $i++; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index e1c2d59b7b8..e6089c00d01 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -96,6 +96,9 @@ function marges_prepare_head() $head[$h][2] = 'checkMargins'; } + complete_head_from_modules($conf,$langs,null,$head,$h,'margins','remove'); + complete_head_from_modules($conf,$langs,null,$head,$h,'margins'); + return $head; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 66f7e288efa..fce619094dc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3584,8 +3584,10 @@ class Product extends CommonObject { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label.= '
' . $langs->trans('ProductAccountancySellCode') . ': '. length_accountg($this->accountancy_code_sell); - $label.= '
' . $langs->trans('ProductAccountancySellIntraCode') . ': '. length_accountg($this->accountancy_code_sell_export); - $label.= '
' . $langs->trans('ProductAccountancySellExportCode') . ': '. length_accountg($this->accountancy_code_sell_intra); + if(!empty($conf->global->MAIN_FEATURES_LEVEL)) { + $label.= '
' . $langs->trans('ProductAccountancySellIntraCode') . ': '. length_accountg($this->accountancy_code_sell_export); + $label.= '
' . $langs->trans('ProductAccountancySellExportCode') . ': '. length_accountg($this->accountancy_code_sell_intra); + } } if (! empty($conf->accounting->enabled) && $this->status_buy) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 7c7619fe0d5..f2d869c9a45 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -159,9 +159,13 @@ $arrayfields=array( //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled) && ! empty($conf->service->enabled))), - 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))), + 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), - 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), + 'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))), + 'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))), + 'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))), + 'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))), + 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), @@ -261,7 +265,7 @@ else } $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql.= ' p.fk_product_type, p.duration, p.weight, p.length, p.surface, p.volume, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; @@ -316,7 +320,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; -$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; +$sql.= " p.fk_product_type, p.duration, p.weight, p.length, p.surface, p.volume, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) $sql .= ', pac.rowid'; // Add fields from extrafields @@ -552,9 +556,32 @@ if ($resql) if (! empty($arrayfields['p.duration']['checked'])) { print ''; } + // Weight + if (! empty($arrayfields['p.weight']['checked'])) + { + print ''; + } + // Length + if (! empty($arrayfields['p.length']['checked'])) + { + print ''; + } + // Surface + if (! empty($arrayfields['p.surface']['checked'])) + { + print ''; + } + // Volume + if (! empty($arrayfields['p.volume']['checked'])) + { + print ''; + } // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) { @@ -650,6 +677,10 @@ if ($resql) if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); @@ -746,7 +777,7 @@ if ($resql) // Label if (! empty($arrayfields['p.label']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } @@ -781,6 +812,39 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } + // Weight + if (! empty($arrayfields['p.weight']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Length + if (! empty($arrayfields['p.length']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Surface + if (! empty($arrayfields['p.surface']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Volume + if (! empty($arrayfields['p.volume']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 5dca091c56b..cdbc49da21e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -509,7 +509,7 @@ else print ''; print ''; $totalunit+=$objp->value; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index bb7f5f0539e..cc7f5d1f2f5 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Laurent Destaileur + * Copyright (C) 2013-2018 Laurent Destaileur * Copyright (C) 2014 Regis Houssin * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2016 ATM Consulting @@ -42,6 +42,9 @@ if ($user->societe_id) { } $result=restrictedArea($user,'produit|service'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('stockreplenishlist')); + //checks if a product has been ordered $action = GETPOST('action','alpha'); @@ -86,6 +89,9 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) $usevirtualstock=0; if ($mode == 'virtual') $usevirtualstock=1; +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); /* * Actions @@ -295,6 +301,12 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre } $sql.= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; $sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; + +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + $sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; $sql.= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; @@ -304,6 +316,12 @@ if ($fk_supplier > 0) { if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; } + +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListJoin',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + $sql.= ' WHERE p.entity IN (' . getEntity('product') . ')'; if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) @@ -384,6 +402,11 @@ if ($usevirtualstock) } } +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1, $offset); @@ -447,9 +470,15 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) print '
'; print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); print '
'; + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) print $hookmanager->resPrint; + print '
'; print ''; print '
'; + print ''; if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { @@ -531,6 +560,12 @@ print '
'; print ''; print ''; @@ -548,6 +583,12 @@ print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $pa print_liste_field_titre('Ordered', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); print_liste_field_titre('StockToBuy', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); print_liste_field_titre('SupplierRef', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); + +// Hook fields +$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + print "\n"; while ($i < ($limit ? min($num, $limit) : $num)) @@ -674,10 +715,20 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Supplier print ''; + // Fields from hook + $parameters=array( 'objp'=>$objp); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print ''; } $i++; } + +$parameters=array('sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + print '
'.$langs->trans("Entities").''; if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); print ''.price($objp->total_ttc).''.price($sign * $objp->total_ttc).''.price($objp->am); + print ''.price($sign * $objp->am); if ($creditnotes) print '+'.price($creditnotes); if ($deposits) print '+'.price($deposits); print ''.price($remaintopay).''.price($sign * $remaintopay).''; diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php index c20b26b1263..b2126aae80b 100644 --- a/htdocs/fourn/facture/rapport.php +++ b/htdocs/fourn/facture/rapport.php @@ -26,6 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement_fourn.class.p require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +$langs->loadLangs(array('bills')); + // Security check $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index e2b6acaec4f..dda4496ca4d 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -326,7 +326,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = x.fk_user_author"; $sql.= " AND x.entity = ".$conf->entity; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')'; diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index d6cefb24d83..2e1c9cb47c1 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -346,7 +346,7 @@ else print ''; print ''; - dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), 0, 'sending'); + dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'sending'); /* * Confirmation de la suppression @@ -607,87 +607,85 @@ else $var=true; while ($i < $num_prod) { + $parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if(empty($reshook)) { - print '
'; + + // Affiche ligne produit + $text = ''; + if ($object->lines[$i]->fk_product_type == 1) $text .= img_object($langs->trans('ShowService'), 'service'); + else $text .= img_object($langs->trans('ShowProduct'), 'product'); + $text .= ' ' . $object->lines[$i]->product_ref . ''; + $text .= ' - ' . $label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description)); + //print $description; + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '
' . dol_htmlentitiesbr($object->lines[$i]->description) : ''; + } + } else { + print "
"; + if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + + if (!empty($object->lines[$i]->label)) { + $text .= ' ' . $object->lines[$i]->label . ''; + print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i); + } else { + print $text . ' ' . nl2br($object->lines[$i]->description); } - $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; - } - else - $label = ( ! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label); - - print ''; - - // Affiche ligne produit - $text = ''; - if ($object->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); - else $text.= img_object($langs->trans('ShowProduct'),'product'); - $text.= ' '.$object->lines[$i]->product_ref.''; - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->description)); - //print $description; - print $form->textwithtooltip($text,$description,3,'','',$i); - print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end); - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($object->lines[$i]->description) && $object->lines[$i]->description!=$object->lines[$i]->product_label)?'
'.dol_htmlentitiesbr($object->lines[$i]->description):''; - } - } - else - { - print "
"; - if ($object->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($object->lines[$i]->label)) { - $text.= ' '.$object->lines[$i]->label.''; - print $form->textwithtooltip($text,$object->lines[$i]->description,3,'','',$i); - } else { - print $text.' '.nl2br($object->lines[$i]->description); + print_date_range($objp->date_start, $objp->date_end); + print "' . $object->lines[$i]->qty_asked . '' . $object->lines[$i]->qty_shipped . ''.$object->lines[$i]->qty_asked.''.$object->lines[$i]->qty_shipped.'
'; - print ' '; print ''; + print ''; + print ''; + print ''; + print ''.dol_trunc($obj->label,40).''.dol_trunc($obj->label, 40).''; + print $obj->weight; + print ''; + print $obj->length; + print ''; + print $obj->surface; + print ''; + print $obj->volume; + print ''.$objp->produit.''; - $valtoshow=price2num($objp->value, 'MS'); + $valtoshow=price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function print empty($valtoshow)?'0':$valtoshow; print '' . $langs->trans('AlertOnly') . '& print '' . $langs->trans('IncludeAlsoDraftOrders') . '  '; + +// Fields from hook +$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).'
'; print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 26b7179b74c..473558f9606 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects','users','companies')); +$hookmanager->initHooks(array('timesheetperdaycard')); + $action=GETPOST('action','aZ09'); $mode=GETPOST("mode",'alpha'); $id=GETPOST('id','int'); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index bf6a95c9e0e..d1434e5e3fb 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects','users','companies')); +$hookmanager->initHooks(array('timesheetperweekcard')); + $action=GETPOST('action','aZ09'); $mode=GETPOST("mode",'alpha'); $id=GETPOST('id','int'); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index a704c7d641e..e63cbe80fee 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -338,7 +338,7 @@ class Project extends CommonObject if (file_exists($olddir)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $res=dol_move($olddir, $newdir); + $res=@rename($olddir, $newdir); if (! $res) { $langs->load("errors"); @@ -723,10 +723,10 @@ class Project extends CommonObject return -1; } } - + /** * Delete tasks with no children first, then task with children recursively - * + * * @param User $user User * @return int <0 if KO, 1 if OK */ @@ -754,7 +754,7 @@ class Project extends CommonObject { if (count($this->lines)) $this->deleteTasks($this->lines); } - + return 1; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 37caf6f4e69..78d21d36424 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -709,8 +709,8 @@ while ($i < min($num,$limit)) // Title if (! empty($arrayfields['p.title']['checked'])) { - print ''; - print dol_trunc($obj->title,80); + print ''; + print dol_trunc($obj->title, 80); print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7fd461000ef..76d627249eb 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -973,7 +973,7 @@ else $object->idprof6 = GETPOST('idprof6', 'alpha'); $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->civility_id = GETPOST('civility_id', 'int'); + $object->civility_id = GETPOST('civility_id', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->status = GETPOST('status', 'int'); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 7b1bf417b40..d7ac16e67ea 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -550,7 +550,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -814,7 +814,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0097eb4715c..14dad44a89d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1783,6 +1783,12 @@ foreach($mainmenuusedarray as $val) $found=1; break; } + else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); + $found=1; + break; + } } // Img file not found if (! $found) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6db383ed515..adcf094e7a4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -855,7 +855,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print $form->selectyesno('admin',GETPOST('admin'),1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if (! empty($conf->use_javascript_ajax)) { @@ -1992,7 +1992,7 @@ else { print $form->selectyesno('admin',$object->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if ($conf->use_javascript_ajax) { diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index dbc413542c4..e1d26c04f8a 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2019 Frédéric France * * 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 @@ -30,9 +31,9 @@ $langs->load("other"); $var = false; $id = GETPOST('id', 'int'); $valueid = GETPOST('valueid', 'int'); -$ref = GETPOST('ref'); -$weight_impact = (float) GETPOST('weight_impact'); -$price_impact = (float) GETPOST('price_impact'); +$ref = GETPOST('ref', 'alpha'); +$weight_impact = GETPOST('weight_impact', 'alpha'); +$price_impact = GETPOST('price_impact', 'alpha'); $price_impact_percent = (bool) GETPOST('price_impact_percent'); $form = new Form($db);