From 34145ed4432416943ee2d00532822a674b9fa7c2 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Sun, 11 Mar 2018 21:58:32 +0100 Subject: [PATCH 001/183] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4d44a4b6fec..9c1cd3cb6bd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f14af2b838f..1deef2e2412 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> "> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d982516bd67..80d8c617c44 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 0a20c2679a1..984af537ea9 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; subprice); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_total_ht); ?> From f91fe41f45e14c673917eb40ece77e04b46f3525 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 19 Mar 2018 15:50:56 +0100 Subject: [PATCH 002/183] prepare invoice selection and calculation --- htdocs/compta/facture/card.php | 54 +++++++++++++++++-- htdocs/compta/facture/class/facture.class.php | 13 +++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1dd7dab2de8..e6ca4650150 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -913,7 +913,7 @@ if (empty($reshook)) // Proprietes particulieres a facture avoir $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = Facture::TYPE_CREDIT_NOTE; - + $id = $object->create($user); if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) @@ -922,6 +922,11 @@ if (empty($reshook)) if ($facture_source->fetch($object->fk_facture_source)>0) { $fk_parent_line = 0; + if ($facture_source->type == Facture::TYPE_SITUATION) + { + $facture_source->fetchPreviousNextSituationInvoice(); + } + foreach($facture_source->lines as $line) { @@ -935,10 +940,51 @@ if (empty($reshook)) if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; } - + + + + + if($facture_source->type == Facture::TYPE_SITUATION) + { + if(!empty($facture_source->tab_previous_situation_invoice)) + { + $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; + $maxPrevSituationPercent = 0; + foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if($prevLine->id == $line->fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); + + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + + + } + } + + // prorata + $line->qty = $line->qty * $maxPrevSituationPercent / 100; + } + + + + // $sql.= ", situation_cycle_ref, situation_counter, situation_final"; + // situation_percent + } + $line->fk_facture = $object->id; $line->fk_parent_line = $fk_parent_line; - + $line->subprice = -$line->subprice; // invert price for object $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here $line->total_ht = -$line->total_ht; @@ -946,7 +992,7 @@ if (empty($reshook)) $line->total_ttc = -$line->total_ttc; $line->total_localtax1 = -$line->total_localtax1; $line->total_localtax2 = -$line->total_localtax2; - + $line->multicurrency_subprice = -$line->multicurrency_subprice; $line->multicurrency_total_ht = -$line->multicurrency_total_ht; $line->multicurrency_total_tva = -$line->multicurrency_total_tva; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8aca7562654..262aac508db 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3495,6 +3495,18 @@ class Facture extends CommonInvoice $return = array(); + + // Select the last situation invoice + $sqlSit = 'SELECT MAX(fs.rowid)'; + $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit.= " WHERE fs.entity = ".$conf->entity; + $sqlSit.= " AND fs.type != ".self::TYPE_SITUATION; + $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit.= " GROUP BY fs.situation_cycle_ref"; + $sqlSit.= " ORDER BY fs.situation_counter"; + + + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; @@ -3506,6 +3518,7 @@ class Facture extends CommonInvoice // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + //$sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; $sql.= " ORDER BY f.facnumber"; From fd86e90df22c5f61bdbca95ef27e156ad62287fb Mon Sep 17 00:00:00 2001 From: John Date: Thu, 22 Mar 2018 11:19:39 +0100 Subject: [PATCH 003/183] Add create creadit note btn --- htdocs/compta/facture/card.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e6ca4650150..61b63315295 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4416,7 +4416,7 @@ else if ($id > 0 || ! empty($ref)) print ''; } } - + // Create a credit note if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $user->rights->facture->creer) { @@ -4425,6 +4425,25 @@ else if ($id > 0 || ! empty($ref)) print ''; } } + + + // For situation invoice with excess received + if ($object->statut == Facture::STATUS_VALIDATED + && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 + && $user->rights->facture->creer + && !$objectidnext + && $object->is_last_in_cycle() + ) + { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + { + print ''; + } else { + print '
' . $langs->trans("CreateCreditNote") . '
'; + } + } + // Create next situation invoice if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { From b4983d0e6d2d710fee4b83f585c750653974ef12 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 22 Mar 2018 11:37:16 +0100 Subject: [PATCH 004/183] FIX invoice filter --- htdocs/compta/facture/class/facture.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 262aac508db..b644e0d05e1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3500,13 +3500,12 @@ class Facture extends CommonInvoice $sqlSit = 'SELECT MAX(fs.rowid)'; $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; $sqlSit.= " WHERE fs.entity = ".$conf->entity; - $sqlSit.= " AND fs.type != ".self::TYPE_SITUATION; + $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; $sqlSit.= " GROUP BY fs.situation_cycle_ref"; $sqlSit.= " ORDER BY fs.situation_counter"; - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; @@ -3518,7 +3517,7 @@ class Facture extends CommonInvoice // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - //$sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; $sql.= " ORDER BY f.facnumber"; From 6a676ea49e2a39ab853503d1864a03d42484a881 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 23 Mar 2018 12:24:47 +0100 Subject: [PATCH 005/183] fix percent --- htdocs/compta/facture/card.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 61b63315295..0eefa2178c3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -914,19 +914,25 @@ if (empty($reshook)) $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = Facture::TYPE_CREDIT_NOTE; + $facture_source = new Facture($db); // fetch origin object + if ($facture_source->fetch($object->fk_facture_source)>0) + { + if ($facture_source->type == Facture::TYPE_SITUATION) + { + $object->situation_counter = $facture_source->situation_counter; + $object->situation_cycle_ref = $facture_source->situation_cycle_ref; + $facture_source->fetchPreviousNextSituationInvoice(); + } + } + $id = $object->create($user); if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) { - $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) + + if (!empty($facture_source->lines)) { $fk_parent_line = 0; - if ($facture_source->type == Facture::TYPE_SITUATION) - { - $facture_source->fetchPreviousNextSituationInvoice(); - } - foreach($facture_source->lines as $line) { @@ -946,6 +952,7 @@ if (empty($reshook)) if($facture_source->type == Facture::TYPE_SITUATION) { + if(!empty($facture_source->tab_previous_situation_invoice)) { $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; @@ -973,7 +980,7 @@ if (empty($reshook)) } // prorata - $line->qty = $line->qty * $maxPrevSituationPercent / 100; + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; } From 88fab15c6090a53cb64756994720ca80e56c3866 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 23 Mar 2018 17:12:09 +0100 Subject: [PATCH 006/183] Change situation display --- htdocs/compta/facture/card.php | 66 +++++++++++++++++------- htdocs/core/class/commonobject.class.php | 4 +- htdocs/langs/en_US/bills.lang | 2 + 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0eefa2178c3..0ae59c31044 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -927,7 +927,7 @@ if (empty($reshook)) $id = $object->create($user); - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if ((GETPOST('invoiceAvoirWithLines', 'int')==1 || $object->situation_cycle_ref>0 ) && $id>0) { if (!empty($facture_source->lines)) @@ -3804,22 +3804,27 @@ else if ($id > 0 || ! empty($ref)) if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices print ''; - print '' . $langs->trans('ListOfPreviousSituationInvoices') . ''; + print '' . $langs->trans('ListOfSituationInvoices') . ''; print ''; + print '' . $langs->trans('Situation') . ''; if (! empty($conf->banque->enabled)) print ''; print '' . $langs->trans('AmountHT') . ''; print '' . $langs->trans('AmountTTC') . ''; print ' '; print ''; - + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; + $current_situation_counter = array(); foreach ($object->tab_previous_situation_invoice as $prev_invoice) { $totalpaye = $prev_invoice->getSommePaiement(); $total_prev_ht += $prev_invoice->total_ht; $total_prev_ttc += $prev_invoice->total_ttc; + $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $prev_invoice->situation_counter; print ''; print '' . $prev_invoice->getNomUrl(1) . ''; print ''; + print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $prev_invoice->situation_counter.''; if (! empty($conf->banque->enabled)) print ''; print '' . price($prev_invoice->total_ht) . ''; print '' . price($prev_invoice->total_ttc) . ''; @@ -3827,27 +3832,46 @@ else if ($id > 0 || ! empty($ref)) print ''; } - - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($total_prev_ht) . ''; - print '' . price($total_prev_ttc) . ''; - print ' '; - print ''; } + + + $total_global_ht += $total_prev_ht ; + $total_global_ttc += $total_prev_ttc ; + $total_global_ht += $object->total_ht; + $total_global_ttc += $object->total_ttc; + $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $object->situation_counter; + print ''; + print '' . $object->getNomUrl(1) . ''; + print ''; + print ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $object->situation_counter.''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($object->total_ht) . ''; + print '' . price($object->total_ttc) . ''; + print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ''; + print ''; + + + print ''; + print '' . $langs->trans('CurrentSituationTotal') . ''; + print ''.implode(' + ', $current_situation_counter).''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($total_global_ht) . ''; + print '' . price($total_global_ttc) . ''; + print ' '; + print ''; + if (count($object->tab_next_situation_invoice) > 0) { // List of next invoices - print ''; + /*print ''; print '' . $langs->trans('ListOfNextSituationInvoices') . ''; print ''; + print ''; if (! empty($conf->banque->enabled)) print ''; print '' . $langs->trans('AmountHT') . ''; print '' . $langs->trans('AmountTTC') . ''; print ' '; - print ''; + print '';*/ $total_next_ht = $total_next_ttc = 0; @@ -3855,9 +3879,11 @@ else if ($id > 0 || ! empty($ref)) $totalpaye = $next_invoice->getSommePaiement(); $total_next_ht += $next_invoice->total_ht; $total_next_ttc += $next_invoice->total_ttc; + print ''; print '' . $next_invoice->getNomUrl(1) . ''; print ''; + print ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?'AS':'S') . $next_invoice->situation_counter.''; if (! empty($conf->banque->enabled)) print ''; print '' . price($next_invoice->total_ht) . ''; print '' . price($next_invoice->total_ttc) . ''; @@ -3865,13 +3891,15 @@ else if ($id > 0 || ! empty($ref)) print ''; } - + + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; + print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) print ''; - - print '' . price($total_next_ht) . ''; - print '' . price($total_next_ttc) . ''; + print '' . price($total_global_ht) . ''; + print '' . price($total_global_ttc) . ''; print ' '; print ''; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e3719d2427..1ba9fc4a65f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2650,7 +2650,7 @@ abstract class CommonObject $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE ) { $prev_sits = $this->get_prev_sits(); @@ -2694,7 +2694,7 @@ abstract class CommonObject $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; $sql .= ' WHERE rowid = '.$this->id; - //print "xx".$sql; + print "xx".$sql; dol_syslog(get_class($this)."::update_price", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 122d1a2a69a..48a2a9d0535 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -339,6 +339,8 @@ PaymentOnDifferentThirdBills=Allow payments on different thirdparties bills but PaymentNote=Payment note ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices +ListOfSituationInvoices=List of situation invoices +CurrentSituationTotal=Total current situation FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years From 70321a8b71258645ba43ac159cdebf19e0d7bbe2 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 3 Apr 2018 15:12:44 +0200 Subject: [PATCH 007/183] add button to remove from cycle --- htdocs/compta/facture/card.php | 21 ++++++++++++++++++++- htdocs/langs/en_US/bills.lang | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cf302c7e206..04337bf8a72 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4478,7 +4478,26 @@ else if ($id > 0 || ! empty($ref)) print '
' . $langs->trans("CreateCreditNote") . '
'; } } - + + // remove situation from cycle + if ($object->statut == Facture::STATUS_VALIDATED + && $user->rights->facture->creer + && !$objectidnext + && $object->is_last_in_cycle() + && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + ) + { + if(($object->total_ttc - $totalcreditnotes) == 0 && false) + { + print ''; + } + else + { + print ''; + } + + } // Create next situation invoice if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 48a2a9d0535..7bab9fd7ac1 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -341,6 +341,8 @@ ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices ListOfSituationInvoices=List of situation invoices CurrentSituationTotal=Total current situation +DisabledBecauseNotEnouthCreditNote=To remove a situation invoice from cycle, this invoice's credit note total must cover this invoice total +RemoveSituationFromCycle=Remove this invoice from cycle FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years From 299859d0c473e3e65127c4df1a1913921f26e492 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 3 Apr 2018 17:34:20 +0200 Subject: [PATCH 008/183] add action to remove from cycle --- htdocs/compta/facture/card.php | 117 ++++++++++++++++++++++++++++----- htdocs/langs/en_US/bills.lang | 5 ++ 2 files changed, 104 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 04337bf8a72..374444e0fbc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2147,6 +2147,65 @@ if (empty($reshook)) header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); } + + // Outing situation invoice from cycle + elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer) + { + $object->fetch($id); + + if ($object->statut == Facture::STATUS_VALIDATED + && $user->rights->facture->creer + && !$objectidnext + && $object->is_last_in_cycle() + && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + //&& ($object->total_ttc - $totalcreditnotes) == 0 + ) + { + $outingError = 0; + $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle + if($newCycle > 1) + { + $lastCycle = $object->situation_cycle_ref; + $object->situation_cycle_ref = $newCycle; + $object->situation_counter = 1; + $object->situation_final = 1; + if($object->update($user) > 0) + { + + // now, credit note must follow + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; + $sql.= ' SET situation_cycle_ref='.intval($newCycle); + $sql.= ' AND situation_counter='.$object->situation_counter; + $sql.= ' WHERE situation_cycle_ref='.intval($lastCycle); + //$sql.= ' AND situation_counter='.$object->situation_counter; + $sql.= ' AND fk_facture_source='.$object->id; + $sql.= ' AND type='.Facture::TYPE_CREDIT_NOTE; + + // TODO : change each progression persent on each lines + + $resql=$db->query($sql); + if ($resql) + { + setEventMessages($langs->trans('Updated')); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + } + else + { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); + } + } + else + { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); + } + } + else + { + setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); + } + } + } // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -3108,6 +3167,24 @@ else if ($id > 0 || ! empty($ref)) $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1); } } + + // Confirmation to remove invoice from cycle + if ($action == 'situationout') { + $text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref); + $label = $langs->trans("ConfirmOuting"); + $formquestion = array(); + // remove situation from cycle + if ($object->statut == Facture::STATUS_VALIDATED + && $user->rights->facture->creer + && !$objectidnext + && $object->is_last_in_cycle() + && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + ) + { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1); + } + } // Confirmation of validation if ($action == 'valid') @@ -3798,23 +3875,27 @@ else if ($id > 0 || ! empty($ref)) if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) { - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) - print ''; + + print '
'; + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; + if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - $total_prev_ht = $total_prev_ttc = 0; - $total_global_ht = $total_global_ttc = 0; $current_situation_counter = array(); foreach ($object->tab_previous_situation_invoice as $prev_invoice) { $totalpaye = $prev_invoice->getSommePaiement(); @@ -3904,8 +3985,7 @@ else if ($id > 0 || ! empty($ref)) print ''; } - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) - print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'; + print ''; } @@ -4483,18 +4563,19 @@ else if ($id > 0 || ! empty($ref)) if ($object->statut == Facture::STATUS_VALIDATED && $user->rights->facture->creer && !$objectidnext + && $object->situation_counter > 1 && $object->is_last_in_cycle() && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) ) { - if(($object->total_ttc - $totalcreditnotes) == 0 && false) + if(($object->total_ttc ) == 0 || true) { - print ''; + print ''; } else { - print ''; + print ''; } } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 7bab9fd7ac1..86dca2d09c3 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -343,6 +343,8 @@ ListOfSituationInvoices=List of situation invoices CurrentSituationTotal=Total current situation DisabledBecauseNotEnouthCreditNote=To remove a situation invoice from cycle, this invoice's credit note total must cover this invoice total RemoveSituationFromCycle=Remove this invoice from cycle +ConfirmRemoveSituationFromCycle=Remove this invoice %s from cycle ? +ConfirmOuting=Confirm outing FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years @@ -509,6 +511,9 @@ SituationAmount=Situation invoice amount(net) SituationDeduction=Situation subtraction ModifyAllLines=Modify all lines CreateNextSituationInvoice=Create next situation +ErrorFindNextSituationInvoice=Error unable to find next situation cycle ref +ErrorOutingSituationInvoiceOnUpdate=Unable to outing this situation invoice. +ErrorOutingSituationInvoiceCreditNote=Unable to outing linked credit note. NotLastInCycle=This invoice is not the latest in cycle and must not be modified. DisabledBecauseNotLastInCycle=The next situation already exists. DisabledBecauseFinal=This situation is final. From ce24ca08eeb7cd81a64c2d35645d5934f52ffea1 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 4 Apr 2018 12:33:48 +0200 Subject: [PATCH 009/183] move list of situation table and fix credit note display --- htdocs/compta/facture/card.php | 273 ++++++++++-------- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/langs/en_US/bills.lang | 2 + 4 files changed, 154 insertions(+), 127 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 374444e0fbc..cb181b8b1b9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -955,7 +955,23 @@ if (empty($reshook)) if(!empty($facture_source->tab_previous_situation_invoice)) { + // search the last invoice in cycle $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while( $searchPreviousInvoice ) + { + if($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice=false; // find, exit; + break; + } + else + { + $lineIndex--; // go to previous invoice in cycle + } + } + + $maxPrevSituationPercent = 0; foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { @@ -981,12 +997,10 @@ if (empty($reshook)) // prorata $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + + } - - - // $sql.= ", situation_cycle_ref, situation_counter, situation_final"; - // situation_percent } $line->fk_facture = $object->id; @@ -3668,7 +3682,7 @@ else if ($id > 0 || ! empty($ref)) print ''; // Situations - if (! empty($conf->global->INVOICE_USE_SITUATION)) + /*if (! empty($conf->global->INVOICE_USE_SITUATION)) { if ($object->type == 5 && ($object->situation_counter > 1)) { @@ -3714,8 +3728,136 @@ else if ($id > 0 || ! empty($ref)) print ''; } } - } + }*/ + + // List of previous situation invoices + if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) + { + + print ''; + + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; + + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices + + $current_situation_counter = array(); + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $totalpaye = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + } + } + + + $total_global_ht += $total_prev_ht ; + $total_global_ttc += $total_prev_ttc ; + $total_global_ht += $object->total_ht; + $total_global_ttc += $object->total_ttc; + $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $object->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + /*print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print '';*/ + + $total_next_ht = $total_next_ttc = 0; + + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaye = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + } + + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; + + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } + + print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . $object->getNomUrl(1) . ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.'' . price($object->total_ht) . '' . price($object->total_ttc) . '' . $object->getLibStatut(3, $object->getSommePaiement()) . '
' . $langs->trans('CurrentSituationTotal') . ''; + $i =0; + foreach ($current_situation_counter as $sit) + { + $curSign = $sit>0?'+':'-'; + $curType = $sit>0?$langs->trans('situationInvoiceShortcode_S'):$langs->trans('situationInvoiceShortcode_AS'); + if($i>0) print ' '.$curSign.' '; + print $curType . abs($sit); + $i++; + } + print '' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
'; + } + + // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -3850,8 +3992,6 @@ else if ($id > 0 || ! empty($ref)) print ''; - // List of previous situation invoices - $sign = 1; if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1; $nbrows = 8; @@ -3873,121 +4013,6 @@ else if ($id > 0 || ! empty($ref)) if (! empty($conf->incoterm->enabled)) $nbrows += 1; - if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) - { - - print ''; - - - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - $total_prev_ht = $total_prev_ttc = 0; - $total_global_ht = $total_global_ttc = 0; - - if (count($object->tab_previous_situation_invoice) > 0) { - // List of previous invoices - - $current_situation_counter = array(); - foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $totalpaye = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $prev_invoice->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - } - } - - - $total_global_ht += $total_prev_ht ; - $total_global_ttc += $total_prev_ttc ; - $total_global_ht += $object->total_ht; - $total_global_ttc += $object->total_ttc; - $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $object->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - if (count($object->tab_next_situation_invoice) > 0) { - // List of next invoices - /*print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print '';*/ - - $total_next_ht = $total_next_ttc = 0; - - foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - } - - $total_global_ht += $total_next_ht; - $total_global_ttc += $total_next_ttc; - - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } - - print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $prev_invoice->situation_counter.'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . $object->getNomUrl(1) . ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $object->situation_counter.'' . price($object->total_ht) . '' . price($object->total_ttc) . '' . $object->getLibStatut(3, $object->getSommePaiement()) . '
' . $langs->trans('CurrentSituationTotal') . ''.implode(' + ', $current_situation_counter).'' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?'AS':'S') . $next_invoice->situation_counter.'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
'; - } - // List of payments already done @@ -4569,7 +4594,7 @@ else if ($id > 0 || ! empty($ref)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) ) { - if(($object->total_ttc ) == 0 || true) + if(($object->total_ttc - $totalcreditnotes ) == 0 ) { print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 68a8be52b50..cd3fdefc554 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1357,8 +1357,8 @@ class Facture extends CommonInvoice $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - - if ($this->type == self::TYPE_SITUATION && $fetch_situation) + + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b88580dfbb8..dabdb88b622 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2694,7 +2694,7 @@ abstract class CommonObject $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; $sql .= ' WHERE rowid = '.$this->id; - print "xx".$sql; + dol_syslog(get_class($this)."::update_price", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 86dca2d09c3..4711c84ef5f 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -517,6 +517,8 @@ ErrorOutingSituationInvoiceCreditNote=Unable to outing linked credit note. NotLastInCycle=This invoice is not the latest in cycle and must not be modified. DisabledBecauseNotLastInCycle=The next situation already exists. DisabledBecauseFinal=This situation is final. +situationInvoiceShortcode_AS=AS +situationInvoiceShortcode_S=S CantBeLessThanMinPercent=The progress can't be smaller than its value in the previous situation. NoSituations=No open situations InvoiceSituationLast=Final and general invoice From e966d11356865dcf4be7ff11d1c4184da6e5c419 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 09:46:55 +0200 Subject: [PATCH 010/183] Fix credit note card apparence --- htdocs/compta/facture/card.php | 1 + htdocs/compta/facture/class/facture.class.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cb181b8b1b9..41e2dcc4a52 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4586,6 +4586,7 @@ else if ($id > 0 || ! empty($ref)) // remove situation from cycle if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext && $object->situation_counter > 1 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cd3fdefc554..93f57f98a3c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1530,8 +1530,16 @@ class Facture extends CommonInvoice $invoice = new Facture($this->db); if ($invoice->fetch($objp->rowid) > 0) { - if ($objp->situation_counter < $this->situation_counter) $this->tab_previous_situation_invoice[] = $invoice; - else $this->tab_next_situation_invoice[] = $invoice; + if ($objp->situation_counter < $this->situation_counter + || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes + ) + { + $this->tab_previous_situation_invoice[] = $invoice; + } + else + { + $this->tab_next_situation_invoice[] = $invoice; + } } } } From b37a2f17bfba7c83026baaf7284fe1e6a12d55cd Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 10:48:20 +0200 Subject: [PATCH 011/183] Fix credit note update on remove from cycle action --- htdocs/compta/facture/card.php | 50 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 41e2dcc4a52..0cc3db47e68 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2165,7 +2165,7 @@ if (empty($reshook)) // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); + $object->fetch($id,'', '','', TRUE); if ($object->statut == Facture::STATUS_VALIDATED && $user->rights->facture->creer @@ -2180,26 +2180,46 @@ if (empty($reshook)) $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle if($newCycle > 1) { + // Search credit notes $lastCycle = $object->situation_cycle_ref; + $lastSituationCounter = $object->situation_counter; + $linkedCreditNotesList = array(); + + if (count($object->tab_next_situation_invoice) > 0) { + foreach ($object->tab_next_situation_invoice as $next_invoice) { + if($next_invoice->type == Facture::TYPE_CREDIT_NOTE + && $next_invoice->situation_counter == $object->situation_counter + && $next_invoice->fk_facture_source == $object->id + ) + { + $linkedCreditNotesList[] = $next_invoice->id ; + } + } + } + $object->situation_cycle_ref = $newCycle; $object->situation_counter = 1; - $object->situation_final = 1; + $object->situation_final = 0; if($object->update($user) > 0) { + $errors = 0; + if(count($linkedCreditNotesList) > 0) + { + // now, credit note must follow + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; + $sql.= ' SET situation_cycle_ref='.$newCycle; + $sql.= ' , situation_final=0'; + $sql.= ' , situation_counter='.$object->situation_counter; + $sql.= ' WHERE rowid IN ('.implode(',',$linkedCreditNotesList).')'; + + // TODO : change each progression persent on each lines + + $resql=$db->query($sql); + if (!$resql) $errors++; + + } - // now, credit note must follow - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql.= ' SET situation_cycle_ref='.intval($newCycle); - $sql.= ' AND situation_counter='.$object->situation_counter; - $sql.= ' WHERE situation_cycle_ref='.intval($lastCycle); - //$sql.= ' AND situation_counter='.$object->situation_counter; - $sql.= ' AND fk_facture_source='.$object->id; - $sql.= ' AND type='.Facture::TYPE_CREDIT_NOTE; - - // TODO : change each progression persent on each lines - - $resql=$db->query($sql); - if ($resql) + if (!$errors) { setEventMessages($langs->trans('Updated')); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); From 689b3e3b64cf44ac54c2b2c33a0681aea30bba11 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 11:25:11 +0200 Subject: [PATCH 012/183] Fix outing invoice ligne progress --- htdocs/compta/facture/card.php | 47 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0cc3db47e68..5fa4dbc918a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2168,12 +2168,12 @@ if (empty($reshook)) $object->fetch($id,'', '','', TRUE); if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext && $object->is_last_in_cycle() && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) - //&& ($object->total_ttc - $totalcreditnotes) == 0 ) { $outingError = 0; @@ -2212,11 +2212,52 @@ if (empty($reshook)) $sql.= ' , situation_counter='.$object->situation_counter; $sql.= ' WHERE rowid IN ('.implode(',',$linkedCreditNotesList).')'; - // TODO : change each progression persent on each lines - $resql=$db->query($sql); if (!$resql) $errors++; + // Change each progression persent on each lines + foreach($object->lines as $line) + { + + // no traitement for special product + if ($line->product_type == 9 ) continue; + + + if(!empty($object->tab_previous_situation_invoice)) + { + // search the last invoice in cycle + $lineIndex = count($object->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while( $searchPreviousInvoice ) + { + if($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice=false; // find, exit; + break; + } + else + { + $lineIndex--; // go to previous invoice in cycle + } + } + + + $maxPrevSituationPercent = 0; + foreach($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if($prevLine->id == $line->fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); + } + } + + + $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; + + if($line->update()<0) $errors++; + + } + } } if (!$errors) From b02f34b038716c561a474f3ab5e9293085e23adc Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 17:13:45 +0200 Subject: [PATCH 013/183] Add line edit progress test --- htdocs/compta/facture/card.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5fa4dbc918a..eb3a9ed2604 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2016,7 +2016,25 @@ if (empty($reshook)) $line->fetch(GETPOST('lineid')); $percent = $line->get_prev_progress($object->id); - if (GETPOST('progress') < $percent) + if($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref>0) + { + // in case of situation credit note + if(GETPOST('progress') >= 0 ) + { + $mesg = $langs->trans("CantBeNullOrPositive"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } + elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result + { + $mesg = $langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } + } + elseif (GETPOST('progress') < $percent) { $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; setEventMessages($mesg, null, 'warnings'); From c044d9ab584705e231a1ee03ad87b13fb5d60730 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 25 Apr 2018 16:20:09 +0200 Subject: [PATCH 014/183] FIX: actioncomm export: type filtering not working --- htdocs/core/modules/modAgenda.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 83175bcdefc..5f78b229461 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -378,7 +378,7 @@ class modAgenda extends DolibarrModules $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", - 'cac.libelle'=>"List:c_actioncomm:libelle:id", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); @@ -400,7 +400,7 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_end[$r] .=' ORDER BY ac.datep'; + $this->export_sql_order[$r]=' ORDER BY ac.datep'; } From 7cedf55c273d36353540c70a5d0fc01f8e94cab4 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 27 Apr 2018 20:54:48 +0200 Subject: [PATCH 015/183] FIX : missing english name for object 'product' is used by API to check perms and return a 401 error even if user has correct permissions --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index a901dd817d5..c9968bb459f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -384,7 +384,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh if ($feature == 'project') $feature='projet'; if ($feature == 'task') $feature='projet_task'; - $check = array('adherent','banque','don','user','usergroup','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object From e79c907ae080d8065b6a58920bc957f489a7e6e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 11:01:33 +0200 Subject: [PATCH 016/183] Fix edit of capital --- htdocs/societe/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e235f6f431c..40e3083e125 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -60,7 +60,7 @@ $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm','alpha'); $socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -181,12 +181,12 @@ if (empty($reshook)) // Merge categories $static_cat = new Categorie($db); - + $custcats_ori = $static_cat->containing($soc_origin->id, 'customer', 'id'); $custcats = $static_cat->containing($object->id, 'customer', 'id'); $custcats = array_merge($custcats,$custcats_ori); $object->setCategories($custcats, 'customer'); - + $suppcats_ori = $static_cat->containing($soc_origin->id, 'supplier', 'id'); $suppcats = $static_cat->containing($object->id, 'supplier', 'id'); $suppcats = array_merge($suppcats,$suppcats_ori); @@ -1885,7 +1885,9 @@ else // Capital print ''.fieldLabel('Capital','capital').''; - print ' '.$langs->trans("Currency".$conf->currency).''; + print ' '.$langs->trans("Currency".$conf->currency).''; // Default language if (! empty($conf->global->MAIN_MULTILANGS)) From ab85fa87219dd4db9982906c72cf0da85c28bfe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 17:45:34 +0200 Subject: [PATCH 017/183] Backport EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS to solve blocking situation. --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f70982fd429..63abda22fed 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -216,7 +216,7 @@ if (empty($reshook)) if ($ret < 0) $error++; } - if ($object->periode_existe($fuser,$object->date_debut,$object->date_fin)) + if (empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser,$object->date_debut,$object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); From d975dd507bc64b760d53840224a532b98a77a089 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 11:17:47 +0200 Subject: [PATCH 018/183] Revert "No display object line curreny if not necessary" --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c1cd3cb6bd..4d44a4b6fec 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 1deef2e2412..f14af2b838f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> "> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 80d8c617c44..d982516bd67 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { + if (!empty($conf->multicurrency->enabled)) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 984af537ea9..0a20c2679a1 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; subprice); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> multicurrency_subprice); ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> multicurrency_total_ht); ?> From b5d720651968b2ad26418f2a1713e2d34792a464 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 1 May 2018 12:02:33 +0200 Subject: [PATCH 019/183] fix 6.0 accountancy multientity --- htdocs/accountancy/admin/account.php | 45 ++++++++++--------- htdocs/accountancy/admin/journals_list.php | 4 +- .../core/class/html.formaccounting.class.php | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 905fd8b97ef..9b1b6746861 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -94,9 +94,9 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if (! empty($cancel)) $action = ''; - + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_account = ""; @@ -106,13 +106,13 @@ if (empty($reshook)) $search_pcgsubtype = ""; $search_array_options=array(); } - + if (GETPOST('change_chart')) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); - + if (! empty($chartofaccounts)) { - + if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -120,12 +120,12 @@ if (empty($reshook)) $error ++; } } - + if ($action == 'disable') { if ($accounting->fetch($id)) { $result = $accounting->account_desactivate($id); } - + $action = 'update'; if ($result < 0) { setEventMessages($accounting->error, $accounting->errors, 'errors'); @@ -165,6 +165,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_vers if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)"; $sql .= " WHERE asy.rowid = " . $pcgver; +$sql .= " AND aa.entity = " . $conf->entity; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); @@ -179,7 +180,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); -} +} $sql .= $db->plimit($limit + 1, $offset); @@ -209,11 +210,11 @@ if ($resql) print ''; print ''; print ''; - + $htmlbuttonadd = '' . $langs->trans("Addanaccount") . ''; - + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $htmlbuttonadd); - + // Box to select active chart of account print $langs->trans("Selectchartofaccounts") . " : "; print '"; print ''; - print '
'; + print '
'; print '
'; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; @@ -259,7 +260,7 @@ if ($resql) print $searchpicto; print ''; print ''; - + print ''; if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"],"aa.account_number","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"],"aa.label","",$param,'',$sortfield,$sortorder); @@ -274,14 +275,14 @@ if ($resql) $accountparent = new AccountingAccount($db); $i=0; - while ($i < min($num, $limit)) + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $accountstatic->id = $obj->rowid; $accountstatic->label = $obj->label; $accountstatic->account_number = $obj->account_number; - + print ''; // Account number @@ -310,7 +311,7 @@ if ($resql) $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; $accountparent->account_number = $obj->account_number2; - + print "\n"; @@ -371,11 +372,11 @@ if ($resql) } print '' . "\n"; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; } - + print "
"; print $accountparent->getNomUrl(1); print "
"; print "
"; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index a3912aebc89..a4718d556f2 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -86,7 +86,7 @@ $tablib[35]= "DictionaryAccountancyJournal"; // Requests to extract data $tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a WHERE a.entity=".$conf->entity; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -102,7 +102,7 @@ $tabfieldvalue[35]= "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature"; +$tabfieldinsert[35]= "code,label,nature,entity"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e3e6e9a4f20..3ae53f44fff 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -273,6 +273,7 @@ class FormAccounting extends Form $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity=".$conf->entity; $sql .= " ORDER BY aa.account_number"; dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); From c84f44a508d2a1a5b60c5468fe18c3340b506a19 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 1 May 2018 12:30:22 +0200 Subject: [PATCH 020/183] fix accountanty in multientity --- .../class/accountancycategory.class.php | 16 ++++++++++++---- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 13 +++++++++++-- .../mysql/tables/llx_accounting_journal.key.sql | 2 +- .../tables/llx_c_accounting_category.key.sql | 2 +- .../mysql/tables/llx_c_accounting_category.sql | 1 + 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 0a538f0a6ae..27254ef31d1 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -360,9 +360,11 @@ class AccountancyCategory // extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ public function display($id) { + global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = " . $id; + $sql .= " AND t.entity = " . $conf->entity; $this->lines_display = array(); @@ -400,13 +402,14 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id . ")"; + $sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; $sql .= " AND t.numero_compte IN ("; $sql .= " SELECT DISTINCT aa.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1)"; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = = " . $conf->entity . ")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; @@ -448,6 +451,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; @@ -492,6 +496,7 @@ class AccountancyCategory // extends CommonObject $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $this->db->begin(); @@ -581,7 +586,7 @@ class AccountancyCategory // extends CommonObject */ public function getCatsCpts() { - global $mysoc; + global $mysoc,$conf; $sql = ""; @@ -595,8 +600,10 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = " . $conf->entity; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = " . $conf->entity; $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); @@ -685,7 +692,7 @@ class AccountancyCategory // extends CommonObject */ public function getCats($categorytype=-1) { - global $db, $langs, $user, $mysoc; + global $db, $langs, $user, $mysoc, $conf; if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); @@ -695,6 +702,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1 "; + $sql .= " AND c.entity = " . $conf->entity; if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " ORDER BY c.position ASC"; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..9fa2849b757 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -9,8 +9,8 @@ -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; -- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); -- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table --- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y -- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; @@ -441,3 +441,12 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; + +ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid; +-- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category +-- VPGSQL8.2 DROP INDEX uk_c_accounting_category +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); +-- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal +-- VPGSQL8.2 DROP INDEX uk_accounting_journal_code +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); + diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql index e5083aa83d7..701c39e06a2 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql @@ -17,4 +17,4 @@ -- =========================================================================== -ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code); +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql index 6b2d520a156..be927f6e761 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql @@ -17,5 +17,5 @@ -- Table with category for accounting account -- =================================================================== -ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code); +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.sql index 253ff6aef46..9df9a9d6ab0 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.sql @@ -22,6 +22,7 @@ CREATE TABLE llx_c_accounting_category ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT 1, code varchar(16) NOT NULL, label varchar(255) NOT NULL, range_account varchar(255) NOT NULL, -- Comment From 8be8249f859d4bf16188fe9e5be7feee71b69c6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 12:40:42 +0200 Subject: [PATCH 021/183] Clean code, fix warnings --- htdocs/core/modules/DolibarrModules.class.php | 14 ++++--------- htdocs/core/modules/modDav.class.php | 14 +------------ .../core/modules/modMultiCurrency.class.php | 15 ------------- htdocs/core/modules/modResource.class.php | 21 +------------------ htdocs/core/modules/modTicketsup.class.php | 14 ------------- 5 files changed, 6 insertions(+), 72 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 7fb9f76119b..70e22bace45 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -158,14 +158,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * // Set this to relative path of js file if module must load a js on all pages * 'js' => '/mymodule/js/mymodule.js', * // Set here all hooks context managed by module - * 'hooks' => array('hookcontext1','hookcontext2'), - * // Set here all workflow context managed by module - * 'workflow' => array( - * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( - * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', - * 'picto'=>'yourpicto@mymodule' - * ) - * ) + * 'hooks' => array('hookcontext1','hookcontext2') * ) */ public $module_parts = array(); @@ -2083,7 +2076,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($value)) { // Can defined other parameters - if (is_array($value['data']) && ! empty($value['data'])) + // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X) + if (isset($value['data']) && is_array($value['data'])) { $newvalue = json_encode($value['data']); if (isset($value['entity'])) $entity = $value['entity']; @@ -2093,7 +2087,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $newvalue = $value['data']; if (isset($value['entity'])) $entity = $value['entity']; } - else + else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...) { $newvalue = json_encode($value); } diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index ae71f02753b..77c3f8feef7 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -80,19 +80,7 @@ class modDav extends DolibarrModules // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /dav/core/modules/barcode) // for specific css file (eg: /dav/css/dav.css.php) - $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array(), // Set this to relative path of css file if module has its own css file - 'js' => array(), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/dav/temp","/dav/subdir"); diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 7908f203c69..7c87ef35a53 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -74,21 +74,6 @@ class modMultiCurrency extends DolibarrModules // for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /multicurrency/core/modules/barcode) // for specific css file (eg: /multicurrency/css/multicurrency.css.php) - //$this->module_parts = array( - // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) - // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - // 'css' => array('/multicurrency/css/multicurrency.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/multicurrency/js/multicurrency.js'), // Set this to relative path of js file if module must load a js on all pages - // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module - // 'dir' => array('output' => 'othermodulename'), // To force the default directories names - // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@multicurrency')) // Set here all workflow context managed by module - // ); $this->module_parts = array(); // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0cf19ec31e2..15b414947ef 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -79,26 +79,7 @@ class modResource extends DolibarrModules // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /resource/core/modules/barcode) // for specific css file (eg: /resource/css/resource.css.php) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory - //'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, - // Set this to 1 if module has its own models directory - //'models' => 0, - // Set this to relative path of css if module has its own css file - //'css' => '/resource/css/resource.css.php', - // Set here all hooks context managed by module - // 'hooks' => array('actioncard','actioncommdao','resource_card','element_resource') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/resource/temp"); diff --git a/htdocs/core/modules/modTicketsup.class.php b/htdocs/core/modules/modTicketsup.class.php index 3dcd3a3423f..594835dad4a 100644 --- a/htdocs/core/modules/modTicketsup.class.php +++ b/htdocs/core/modules/modTicketsup.class.php @@ -82,22 +82,8 @@ class modTicketsup extends DolibarrModules $this->module_parts = array( // Set this to 1 if module has its own trigger directory 'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, // Set this to 1 if module has its own models directory 'models' => 1, - // Set this to relative path of css if module has its own css file - //'css' => '', - // Set here all hooks context managed by module - 'hooks' => array('admin') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) ); // Data directories to create when module is enabled. From 3340598cf8256a74dd9dad0b01646e8ffa4da838 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 14:15:11 +0200 Subject: [PATCH 022/183] FIX Projet is not prefilled when created from overwiew page --- htdocs/commande/card.php | 14 ++++++-------- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/supplier_proposal/card.php | 11 +++++------ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0844facca69..9f55311444b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -28,9 +28,9 @@ */ /** - * \file htdocs/commande/card.php + * \file htdocs/commande/card.php * \ingroup commande - * \brief Page to show customer order + * \brief Page to show customer order */ require '../main.inc.php'; @@ -76,6 +76,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility @@ -228,7 +229,7 @@ if (empty($reshook)) // Link to a project else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid','int')); } // Add order @@ -259,8 +260,8 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private','none'); $object->note_public = GETPOST('note_public','none'); $object->source = GETPOST('source_id'); - $object->fk_project = GETPOST('projectid'); - $object->ref_client = GETPOST('ref_client'); + $object->fk_project = GETPOST('projectid','int'); + $object->ref_client = GETPOST('ref_client','alpha'); $object->modelpdf = GETPOST('model'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -1389,7 +1390,6 @@ if ($action == 'create' && $user->rights->commande->creer) if ($socid > 0) $res = $soc->fetch($socid); - $projectid = 0; $remise_absolue = 0; $currency_code = $conf->currency; @@ -1486,7 +1486,6 @@ if ($action == 'create' && $user->rights->commande->creer) $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; - $projectid = 0; if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1494,7 +1493,6 @@ if ($action == 'create' && $user->rights->commande->creer) $note_public = $object->getDefaultCreateValueFor('note_public'); } - print '
'; print ''; print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index b6649250e64..2828963d889 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -349,7 +349,7 @@ if ($action == 'create') print '
'; print ''; print '   '; - print ''; + print ''; print '
'; print '
'; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a5488959016..8c2bfb8090a 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -67,6 +67,7 @@ $action = GETPOST('action', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); +$projectid = GETPOST('projectid', 'int'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid','int'); @@ -265,7 +266,7 @@ if (empty($reshook)) $object->remise_percent = GETPOST('remise_percent'); $object->remise_absolue = GETPOST('remise_absolue'); $object->socid = GETPOST('socid'); - $object->fk_project = GETPOST('projectid'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note','none'); @@ -283,7 +284,7 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = GETPOST('projectid'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note','none'); @@ -890,7 +891,7 @@ if (empty($reshook)) // Set project else if ($action == 'classin' && $user->rights->supplier_proposal->creer) { - $object->setProject($_POST['projectid']); + $object->setProject(GETPOST('projectid'),'int'); } // Delai de livraison @@ -1103,9 +1104,7 @@ if ($action == 'create') $formproject = new FormProjets($db); - $projectid = 0; - if ($origin == 'project') - $projectid = ($originid ? $originid : 0); + if ($origin == 'project') $projectid = ($originid ? $originid : 0); print ''; print '' . $langs->trans("Project") . ''; From c3b5664fb51f3573cb8bbb0bd0ab2f47242609e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:24:40 +0200 Subject: [PATCH 023/183] Fix sort order of email templates --- htdocs/admin/mails_templates.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d282acd3447..4e731021199 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -169,10 +169,6 @@ if ($conf->adherent->enabled) $elementList['member']=$langs->trans('Mai if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); -sort($elementList); -// Add all and none after the sort -$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; -$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -182,6 +178,12 @@ if ($reshook == 0) { } } +// Add all and none after the sort +$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; +$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; + +asort($elementList); + $id = 25; @@ -211,7 +213,7 @@ if (empty($reshook)) } // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd') || GETPOST('actionmodify')) + if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -227,7 +229,7 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { @@ -269,8 +271,8 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null"; + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -316,12 +318,16 @@ if (empty($reshook)) if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + +// print $keycode.' - '.$_POST[$keycode].'
'; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - +//print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 14fd740b04a08e115a1972604d0cb3f8ac3fe7e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:25:06 +0200 Subject: [PATCH 024/183] Fix lang must be '' and not empty in email_template --- htdocs/accountancy/admin/accountmodel.php | 23 +++---------------- .../install/mysql/migration/7.0.0-8.0.0.sql | 1 + 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index db9725ce9f6..f8a31b239bb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -617,25 +617,13 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); } print ''; - if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') - { - print ''; - } + print ''; print ''; print ""; @@ -1134,16 +1122,11 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') } elseif (in_array($fieldlist[$field], array('content'))) { - if ($tabname == MAIN_DB_PREFIX.'c_email_templates') - { - print ''; // To create an artificial CR for the current tr we are on - } - else print ''; + print ''; if ($context != 'hide') { //print ''; $okforextended=true; - if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); print $doleditor->Create(1); } diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..287c3bb6aaa 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -441,3 +441,4 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; +update llx_c_email_templates set lang = '' where lang IS NULL; From cb76d2ce0f8d3c4dcd43ecd0b7b217080312db3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 18:58:19 +0200 Subject: [PATCH 025/183] Better logging --- htdocs/core/class/menubase.class.php | 3 ++ htdocs/core/modules/DolibarrModules.class.php | 28 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a96f62e8cbc..c123356f9ab 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -124,6 +124,9 @@ class Menubase else dol_print_error($this->db); } + // TODO + // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; $sql.= "menu_handler,"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 70e22bace45..a5211b11b5e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -953,7 +953,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$entity.")"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active delect activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -965,7 +965,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", 0, ".$entity; $sql.= ", '".$this->db->escape($note)."')"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1133,6 +1133,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->boxes)) { + dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); + $pos_name = InfoBox::getListOfPagesForBoxes(); foreach ($this->boxes as $key => $value) @@ -1150,7 +1152,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " AND entity = ".$conf->entity; if ($note) $sql.=" AND note ='".$this->db->escape($note)."'"; - dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1304,6 +1305,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->cronjobs)) { + dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); + foreach ($this->cronjobs as $key => $value) { $entity = isset($this->cronjobs[$key]['entity'])?$this->cronjobs[$key]['entity']:$conf->entity; @@ -1332,7 +1335,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $now=dol_now(); - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1369,7 +1371,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= "'".$this->db->escape($test)."'"; $sql.= ")"; - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1466,6 +1467,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! empty($this->tabs)) { + dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); + $i=0; foreach ($this->tabs as $key => $value) { @@ -1499,7 +1502,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -1532,6 +1534,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (empty($this->const)) return 0; + dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); + foreach ($this->const as $key => $value) { $name = $this->const[$key][0]; @@ -1567,8 +1571,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ",".$entity; $sql.= ")"; - - dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); if (! $this->db->query($sql) ) { $err++; @@ -1638,13 +1640,14 @@ class DolibarrModules // Can not be abstract, because we need to insta $err=0; $entity=(! empty($force_entity) ? $force_entity : $conf->entity); + dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); + // Test if module is activated $sql_del = "SELECT ".$this->db->decrypt('value')." as value"; $sql_del.= " FROM ".MAIN_DB_PREFIX."const"; $sql_del.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql_del.= " AND entity IN (0,".$entity.")"; - dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); $resql=$this->db->query($sql_del); if ($resql) @@ -1802,6 +1805,8 @@ class DolibarrModules // Can not be abstract, because we need to insta require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; + dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG); + $err=0; $this->db->begin(); @@ -2110,7 +2115,8 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG); + dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); + $resql=$this->db->query($sql,1); if (! $resql) { @@ -2121,7 +2127,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } else { - dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING); + dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING); } } } From 5e14b165c93c1429e0bf30c988f901ad018382d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 19:51:53 +0200 Subject: [PATCH 026/183] NEW Show last result code of cron jobs in error in red --- htdocs/cron/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 81e9d57c03b..61b31d37131 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -508,7 +508,10 @@ if ($num > 0) print ''; print ''; - if ($obj->lastresult != '') {print dol_trunc($obj->lastresult);} + if ($obj->lastresult != '') { + if (empty($obj->lastresult)) print $obj->lastresult; + else print ''.dol_trunc($obj->lastresult).''; + } print ''; print ''; From dc9892f803a08e96156c6bea1ee86f183859aca9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:17:03 +0200 Subject: [PATCH 027/183] Fix bad log --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2094cd10c5c..2e345a48276 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6181,7 +6181,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object { $module=$reg[1]; - dol_syslog("Library functions_".$substitfile['name']." found into ".$dir); + dol_syslog("Library ".$substitfile['name']." found into ".$dir); // Include the user's functions file require_once $dir.$substitfile['name']; // Call the user's function, and only if it is defined From 124abd39b6355b8aea21bae426172ede290e31e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:31:57 +0200 Subject: [PATCH 028/183] Code comment --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 28c6f86769f..c275dd6cda3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -105,7 +105,7 @@ function dol_decode($chain, $key='1') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ From 2f2d17926ddf917d860cac85f5ac5dc2e7b6393d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:52:25 +0200 Subject: [PATCH 029/183] Sort list --- htdocs/admin/security.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9627164f534..38cd2d12c1b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -127,7 +127,7 @@ if ($action == 'activate_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); @@ -135,7 +135,7 @@ if ($action == 'activate_encryptdbpassconf') } else { - setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); + setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); } } else if ($action == 'disable_encryptdbpassconf') @@ -144,7 +144,7 @@ else if ($action == 'disable_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); header("Location: security.php"); @@ -233,6 +233,7 @@ if (is_resource($handle)) } closedir($handle); } +asort($arrayhandler); print ''; print ''; @@ -299,42 +300,42 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print '
'.$langs->trans("PasswordPatternDesc").'
' . $langs->trans("MinLength")."
' . $langs->trans("NbMajMin")."
' . $langs->trans("NbNumMin")."
' . $langs->trans("NbSpeMin")."
' . $langs->trans("NbIteConsecutive")."
' . $langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'; print '
'; From 42dee75ba3dc3a5ed83987f880c4c3b0e306755e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 1 May 2018 23:32:35 +0100 Subject: [PATCH 030/183] Add: Overload styles files from a current folder of module & theme My goal is to overload css files only for the current module and without changing the source code of the module but just by adding a folder style in the module folder. Then just place the css files to overload in this folder they will be automatically added in the head. The same method is applied to the current theme. To test, for example, place a custom.css file in the societe/style/custom.css folder and check the head of a company module page. --- htdocs/main.inc.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f1d6487d5de..19e74d1ddc2 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1206,6 +1206,54 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; + //Overload css files to the current theme + // Check if the /theme/nameoftheme/style folder exists and Add the contains css files to head + if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) + { + //browse the css dir and add the contains css files + if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) + { + while (false !== ($entry = readdir($handle))) + { + list($filename, $extension) = explode(".", $entry); + if ($entry !== '.' && $entry !== '..' && $extension == 'css') + { + print ''."\n"; + } + } + closedir($handle); + } + } + + //Overload css files to the current module + // Check if the /module/style folder exists and Add the contains css files to head + $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); + if(is_array($cur_modulepart) && count($cur_modulepart)>0) + { + foreach($conf->modules as $module) + { + if(in_array($module, $cur_modulepart)) + { + if (file_exists(getcwd().DIRECTORY_SEPARATOR."style")) + { + //browse the style dir and add the contains css files + if ($handle = opendir(getcwd().DIRECTORY_SEPARATOR."style")) + { + while (false !== ($entry = readdir($handle))) + { + list($filename, $extension) = explode(".", $entry); + if ($entry !== '.' && $entry !== '..' && $extension == 'css') + { + print ''."\n"; + } + } + closedir($handle); + } + } + } + } + } + // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From 886ad9d4b644b295bbc673b98ec437d84f5945f5 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 08:45:18 +0200 Subject: [PATCH 031/183] check eldy message --- htdocs/accountancy/admin/account.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 9b1b6746861..1c845716e6b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -160,12 +160,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity; // Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)"; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER) AND a2.entity = " . $conf->entity; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED) AND a2.entity = " . $conf->entity; $sql .= " WHERE asy.rowid = " . $pcgver; -$sql .= " AND aa.entity = " . $conf->entity; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); From 12440e6a7e62087adb32a07b17abf9f64ac9f018 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 2 May 2018 11:30:35 +0200 Subject: [PATCH 032/183] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 046097eec86..4c236324373 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3677,7 +3677,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3716,7 +3716,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index fdef8a03ed8..61818d4deb9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -111,7 +111,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -345,7 +345,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> "> @@ -462,7 +462,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index a6f5fef5310..d3dc9807c5a 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -53,7 +53,7 @@ $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc if (in_array($object->element,array('propal','supplier_proposal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button if (empty($user->rights->margins->creer)) $colspan++; -if (!empty($conf->multicurrency->enabled)) $colspan+=2; +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; ?> @@ -148,7 +148,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f48b0b917a1..b36159f9340 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -195,7 +195,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; subprice); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> @@ -261,7 +261,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; trans('Option'); ?> total_ht); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> multicurrency_total_ht); ?> From 73c3529831ce3b4eabc38afaece66d3f5f12784d Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 2 May 2018 14:36:55 +0200 Subject: [PATCH 033/183] NEW : Display price HT on all commercial area boards --- htdocs/comm/index.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 48d989d0cdc..eab813653d6 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -349,7 +349,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'customer',16); print ''; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } $i++; $total += $obj->total_ttc; } @@ -432,7 +437,12 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'supplier',16); print ''; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } $i++; $total += $obj->total_ttc; } @@ -744,7 +754,12 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } print ''.$propalstatic->LibStatut($obj->fk_statut,3).''."\n"; print ''."\n"; $i++; @@ -843,7 +858,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } print ''.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).''."\n"; print ''."\n"; $i++; From a20ec7ba1eea98d87297cbe0b6b4699fb3eb584e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 2 May 2018 14:37:35 +0200 Subject: [PATCH 034/183] NEW cancel orders on massaction --- htdocs/commande/list.php | 3 +++ htdocs/core/actions_massactions.inc.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 872d6f02bfa..ee2fa05656d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -208,6 +208,7 @@ if (empty($reshook)) $uploaddir = $conf->commande->dir_output; $trigger_name='ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + } @@ -419,6 +420,8 @@ if ($resql) $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), + 'cancelorders'=>$langs->trans("Cancel"), + ); if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4894212fa07..6303d78d6ef 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -736,6 +736,20 @@ if ($massaction == 'confirm_createbills') } } +if ($massaction == 'cancelorders') +{ + $orders = GETPOST('toselect', 'array'); + foreach ($orders as $id_order) + { + + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) + continue; + $cmd->cancel(); + } +} + + if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { if (empty($diroutputmassaction)) From 21b387a4c45d9ff57f943aafed328ab562b40626 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 2 May 2018 15:01:32 +0200 Subject: [PATCH 035/183] NEW thirdparty categ filter on lists --- htdocs/comm/propal/list.php | 20 ++++++++++++++++++++ htdocs/commande/list.php | 17 +++++++++++++++++ htdocs/compta/facture/list.php | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 84710999183..d5d155ce0bf 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -76,6 +76,7 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $viewstatut=GETPOST('viewstatut','alpha'); $optioncss = GETPOST('optioncss','alpha'); @@ -205,6 +206,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $object_statut=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if ($object_statut != '') $viewstatut=$object_statut; @@ -248,6 +251,8 @@ $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -258,6 +263,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'propal as p'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; @@ -294,6 +301,9 @@ if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; + if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($viewstatut != '' && $viewstatut != '-1') @@ -386,6 +396,8 @@ if ($resql) if ($search_zip) $param.='&search_zip='.urlencode($search_zip); if ($socid > 0) $param.='&socid='.urlencode($socid); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -464,6 +476,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 872d6f02bfa..b5e6e0de523 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -73,6 +73,7 @@ $socid=GETPOST('socid','int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); $search_total_ht=GETPOST('search_total_ht','alpha'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $optioncss = GETPOST('optioncss','alpha'); $billed = GETPOST('billed','int'); $viewstatut=GETPOST('viewstatut'); @@ -193,6 +194,7 @@ if (empty($reshook)) $billed=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; } if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) @@ -237,6 +239,8 @@ $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_clie $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql.= ' c.date_creation as date_creation, c.tms as date_update,'; $sql.= " p.rowid as project_id, p.ref as project_ref"; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -247,6 +251,7 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; @@ -327,6 +332,8 @@ if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$sear if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); if ($search_project_ref != '') $sql.= natural_search("p.ref",$search_project_ref); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -412,6 +419,8 @@ if ($resql) if ($show_files) $param.='&show_files=' .urlencode($show_files); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($billed != '') $param.='&billed='.urlencode($billed); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -538,6 +547,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 61383941c10..29a98c0541b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -96,6 +96,7 @@ $search_year = GETPOST('search_year','int'); $search_day_lim = GETPOST('search_day_lim','int'); $search_month_lim = GETPOST('search_month_lim','int'); $search_year_lim = GETPOST('search_year_lim','int'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $option = GETPOST('search_option'); if ($option == 'late') { @@ -228,6 +229,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','a $search_month_lim=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if (empty($reshook)) @@ -369,6 +372,8 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -379,6 +384,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)"; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; @@ -435,6 +442,8 @@ if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_va if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; if ($search_status != '' && $search_status >= 0) { if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft @@ -566,6 +575,8 @@ if ($resql) if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -657,6 +668,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; From 942e2f40bf6afe5e16d6dfd9543ad50aa963a626 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 2 May 2018 17:07:27 +0200 Subject: [PATCH 036/183] addline manage rank on its own if not provided --- htdocs/fourn/class/fournisseur.facture.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c1337452d8a..34609a8fa33 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1383,6 +1383,11 @@ class FactureFournisseur extends CommonInvoice if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + if ($rang < 0) { + $rangmax = $this->line_max(); + $rang = $rangmax + 1; + } + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code From 739317a794eedeab00bea35ae2895b223351879e Mon Sep 17 00:00:00 2001 From: bafbes Date: Wed, 2 May 2018 08:10:58 +0100 Subject: [PATCH 037/183] New : option to show database name in upper help menu --- htdocs/main.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 72a7327a1a1..eaea0dc420c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1581,6 +1581,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($helpbaseurl && $helppage) { $text=''; + if(!empty($conf->global->MAIN_SHOWDATABASENAMEINHELPPAGESLINK)) { + $langs->load('admin'); + $appli .= '
' . $langs->trans("Database") . ': ' . $db->database_name; + } $title=$appli.'
'; $title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'); if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' "'.dol_escape_htmltag(strtr($helppage,'_',' ')).'"'; From d0fafc812e18d165ecc413c60514ab51871e9480 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:04:59 +0200 Subject: [PATCH 038/183] Fix include of strip class only when required --- .../triggers/interface_80_modStripe_Stripe.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index b6428c51b28..cef63a474e6 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -28,8 +28,9 @@ * - Le nom de la propriete name doit etre Mytrigger */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -dol_include_once('/stripe/class/stripe.class.php'); $path=dirname(__FILE__).'/'; + + /** * Class of triggers for stripe module */ @@ -47,8 +48,8 @@ class InterfaceStripe $this->db = $db; $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = 'Stripeconnect'; - $this->description = "Triggers of the module Stripeconnect"; + $this->family = 'stripe'; + $this->description = "Triggers of the module Stripe"; $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version $this->picto = 'stripe@stripe'; } @@ -120,7 +121,10 @@ class InterfaceStripe $langs->load('other'); $ok = 0; + + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); + if (empty($conf->stripe->enabled)) return 0; $service = 'StripeTest'; From dfe6e4bfc1484e0f8dafe277ba9d2dfeafa508f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:08:59 +0200 Subject: [PATCH 039/183] Doxygen --- htdocs/admin/modulehelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index b90fa10e211..8d44421186d 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/admin/modules.php + * \file htdocs/admin/modulehelp.php * \brief Page to activate/disable all modules */ From 24518803fc948fc0fe26aee1adfe77c498e6f2a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:15:16 +0200 Subject: [PATCH 040/183] Clean code --- htdocs/admin/notification.php | 4 ---- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 2 +- .../core/triggers/interface_50_modLdap_Ldapsynchro.class.php | 5 +++-- .../interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 5 +++-- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 5f57ac99efc..f71bc87fc2d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -128,8 +128,6 @@ print '
'; print ''; print ''; -$var=true; - print ''; print ''; print ''; @@ -168,7 +166,6 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); print ''; print '\n"; $notificationtrigger=new InterfaceNotification($db); $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); -$var=true; foreach($listofnotifiedevents as $notifiedevent) { diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 6666cdec47b..2750834bac6 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -23,7 +23,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; /** @@ -56,6 +55,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; $b=new BlockedLog($this->db); // Tracked events diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 8cfece7dc89..7677c1743a8 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -24,8 +24,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; -require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; /** @@ -60,6 +58,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers return 0; } + require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; + require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; + $result=0; // Users diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index ecf57316c89..44a6645a6d7 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -22,8 +22,6 @@ * \brief File to manage triggers Mailman and Spip */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; -require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; /** @@ -51,6 +49,9 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers { if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing + require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; + require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; + if ($action == 'CATEGORY_LINK') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index cef63a474e6..7d4680be3f9 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -28,7 +28,6 @@ * - Le nom de la propriete name doit etre Mytrigger */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -$path=dirname(__FILE__).'/'; /** @@ -122,7 +121,7 @@ class InterfaceStripe $ok = 0; - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); if (empty($conf->stripe->enabled)) return 0; From 3657857d2160ba759f0f2429aa5e119d122b3026 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 19:29:18 +0200 Subject: [PATCH 041/183] fix project and task visibility same as list --- htdocs/projet/activity/perday.php | 3 ++- htdocs/projet/activity/perweek.php | 3 ++- htdocs/projet/class/project.class.php | 19 ++++++++------ htdocs/projet/class/task.class.php | 38 ++++++++++++++------------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 36b55ea79ff..b4329ac9237 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -49,7 +49,8 @@ $projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +// For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 438d71cbdba..591f8b3ab6f 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -50,7 +50,8 @@ $projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +// For external user, no check is done on company because readability is managed by public status of project and assignement. +// if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ea304eaabe0..551bdcb9d5f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1662,23 +1662,26 @@ class Project extends CommonObject { global $conf, $langs; - $mine=0; $socid=$user->societe_id; - - $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); + // For external user, no check is done on company because readability is managed by public status of project and assignement. + //$socid=$user->societe_id; + if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1,$socid); + $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= ")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + // For external user, no check is done on company permission because readability is managed by public status of project and assignement. + //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql.= " WHERE p.fk_statut = 1"; $sql.= " AND p.entity IN (".getEntity('project', 0).')'; - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + // For external user, no check is done on company permission because readability is managed by public status of project and assignement. + //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + //print $sql; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 1c8b1466483..6beafe71a25 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1701,29 +1701,31 @@ class Task extends CommonObject { global $conf, $langs; - $mine=0; $socid=$user->societe_id; - + // For external user, no check is done on company because readability is managed by public status of project and assignement. + //$socid=$user->societe_id; + $projectstatic = new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; - // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - //print $sql; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND p.fk_statut = 1"; + $sql.= " AND t.fk_projet = p.rowid"; + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + //print $sql; $resql=$this->db->query($sql); if ($resql) { From 46e94af5949c233dc165b20af77048d0f9852482 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 19:46:04 +0200 Subject: [PATCH 042/183] fix taskid --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 3d239921c60..c3f1da54a16 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -756,7 +756,7 @@ while ($i < min($num,$limit)) $showlineingray=0;$showproject=1; print ''; print ''; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/livraison/doc/"); @@ -452,7 +448,6 @@ print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -460,7 +455,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 7abb16a0729..3aa3b3364c0 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -27,8 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -$langs->load("admin"); -$langs->load("mails"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "mails")); if (!$user->admin) accessforbidden(); @@ -105,29 +105,24 @@ print ''; print ''; print ''; -$var=true; - print '
'.$langs->trans("Parameter").'
'; -$var=true; $i=0; foreach($listofnotifiedevents as $notifiedevent) { @@ -212,7 +209,6 @@ print "
'; if ($showlineingray) print ''; - else print ''; + else print ''; if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; From 9e18c95a3f9547bdfa400fcf0be11df8cb0391e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:54:07 +0200 Subject: [PATCH 043/183] Fix migration script --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index cf99009100e..3ca87e97053 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -442,11 +442,11 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid; --- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category --- VPGSQL8.2 DROP INDEX uk_c_accounting_category +-- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category; +-- VPGSQL8.2 DROP INDEX uk_c_accounting_category; ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); --- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal --- VPGSQL8.2 DROP INDEX uk_accounting_journal_code +-- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal; +-- VPGSQL8.2 DROP INDEX uk_accounting_journal_code; ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; From db76fd7895233bb13e1996fd8b800cf1048d9dd5 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 2 May 2018 22:33:23 +0200 Subject: [PATCH 044/183] Fix delete all product variants of a parent product User object missing --- htdocs/product/class/product.class.php | 2 +- htdocs/variants/class/ProductCombination.class.php | 9 +++++---- htdocs/variants/generator.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e36d5970e8f..e989b0eb206 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1116,7 +1116,7 @@ class Product extends CommonObject //If it is a parent product, then we remove the association with child products $prodcomb = new ProductCombination($this->db); - if ($prodcomb->deleteByFkProductParent($id) < 0) { + if ($prodcomb->deleteByFkProductParent($user, $id) < 0) { $error++; $this->errors[] = 'Error deleting combinations'; } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4f647aa2cb3..92bba2f70f8 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -275,10 +275,11 @@ class ProductCombination /** * Deletes all product combinations of a parent product * - * @param int $fk_product_parent Rowid of parent product + * @param User $user Object user + * @param int $fk_product_parent Rowid of parent product * @return int <0 KO >0 OK */ - public function deleteByFkProductParent($fk_product_parent) + public function deleteByFkProductParent($user, $fk_product_parent) { $this->db->begin(); @@ -289,11 +290,11 @@ class ProductCombination $res = $prodstatic->fetch($prodcomb->fk_product_child); if ($res > 0) { - $res = $prodcomb->delete(); + $res = $prodcomb->delete($user); } if ($res > 0 && !$prodstatic->isObjectUsed($prodstatic->id)) { - $res = $prodstatic->delete(); + $res = $prodstatic->delete($user); } if ($res < 0) { diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index d4162899874..4daa2d8f45a 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -95,7 +95,7 @@ if ($_POST) { $delete_prev_comb_res = 1; if (!$donotremove) { - $delete_prev_comb_res = $combination->deleteByFkProductParent($id); + $delete_prev_comb_res = $combination->deleteByFkProductParent($user, $id); } //Current combinations will be deleted From bca8d0844e97765139ad0babfcd7f033d4e06f03 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 3 May 2018 00:38:38 +0100 Subject: [PATCH 045/183] Prepare the adding pdf models to the stock module --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 3ca87e97053..51b83612983 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -451,3 +451,7 @@ ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code ( UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; +-- Warehouse +ALTER TABLE `llx_entrepot` ADD `model_pdf` VARCHAR(255) AFTER `fk_user_author`; +ALTER TABLE `llx_stock_mouvement` ADD `model_pdf` VARCHAR(255) AFTER `origintype`; + From 2cf1aa967c5a327f4968a07b5620ad999c19ad98 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 3 May 2018 01:01:05 +0100 Subject: [PATCH 046/183] Add warehouse models pdf --- htdocs/core/modules/modStock.class.php | 83 +- .../doc/doc_generic_stock_odt.modules.php | 503 +++++++ .../stock/doc/pdf_standard.modules.php | 1158 ++++++++++++++++ .../stock/doc/pdf_stdmouvement.modules.php | 1159 +++++++++++++++++ .../modules/stock/modules_stock.class.php | 90 ++ htdocs/core/modules/stock/modules_stock.php | 52 + 6 files changed, 3041 insertions(+), 4 deletions(-) create mode 100644 htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php create mode 100644 htdocs/core/modules/stock/doc/pdf_standard.modules.php create mode 100644 htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php create mode 100644 htdocs/core/modules/stock/modules_stock.class.php create mode 100644 htdocs/core/modules/stock/modules_stock.php diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ca518ed8851..55c0bfe6410 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -60,7 +60,7 @@ class modStock extends DolibarrModules $this->picto='stock'; // Data directories to create when module is enabled - $this->dirs = array(); + $this->dirs = array("/stock/temp"); $this->config_page_url = array("stock.php"); @@ -70,9 +70,38 @@ class modStock extends DolibarrModules $this->langfiles = array("stocks"); // Constants - $this->const = array( - 0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1) - ); + $this->const = array(); + $r=0; + + $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1); + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "Standard"; + $this->const[$r][3] = 'Name of PDF model of stock'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "StdMouvement"; + $this->const[$r][3] = 'Name of PDF model of stock mouvement'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; // Boxes $this->boxes = array(); @@ -266,4 +295,50 @@ class modStock extends DolibarrModules ); } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + global $conf,$langs; + + // Permissions + $this->remove($options); + + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/stock'; + $dest=$dirodt.'/template_stock.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array(); + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")", + ); + + return $this->_init($sql,$options); + } } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php new file mode 100644 index 00000000000..0cadf3362d4 --- /dev/null +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -0,0 +1,503 @@ + + * Copyright (C) 2012 Juanjo Menent +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* or see http://www.gnu.org/ +*/ + +/** + * \file htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php + * \ingroup societe + * \brief File of class to build ODT documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/stock/class/stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_stock_odt extends ModelePDFStock +{ + var $emetteur; // Objet societe qui emet + + var $phpmin = array(5,2,0); // Minimum version of PHP required by module + var $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'STOCK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Dimension page pour format A4 + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva STOCK_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + function info($langs) + { + global $conf,$langs; + + $langs->load("companies"); + $langs->load("errors"); + + $form = new Form($this->db); + + $texte = $this->description.".
\n"; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + $texte.= ''; + $texte.= ''; + $texte.= ''; + } + $texte.= ''; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
'; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->STOCK_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); + else + { + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + + // Scan directories + if (count($listofdir)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + + /*if ($conf->global->MAIN_STOCK_CHOOSE_ODT_DOCUMENT > 0) + { + // Model for creation + $liste=ModelePDFStock::liste_modeles($this->db); + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '"; + + $texte.= ''; + $texte.= ''; + $texte.= '"; + $texte.= ''; + + $texte.= ''; + $texte.= '"; + $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value2',$liste,$conf->global->STOCK_ADDON_PDF_ODT_DEFAULT); + $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; + $texte.= $form->selectarray('value3',$liste,$conf->global->STOCK_ADDON_PDF_ODT_TOBILL); + $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''; + $texte.= $form->selectarray('value4',$liste,$conf->global->STOCK_ADDON_PDF_ODT_CLOSED); + $texte.= "
'; + }*/ + } + + $texte.= '
'; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
'; + $texte.= ''; + + return $texte; + } + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $stock,$langs,$conf,$mysoc,$hookmanager,$user; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + if ($conf->produit->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Stock($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db,$object->error); + return -1; + } + } + $stockFournisseur = new StockFournisseur($this->db); + $supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $dir = $conf->produit->dir_output; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); + + $newfiletmp=$objectref.'_'.$newfiletmp; + + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->produit->dir_temp=".$conf->produit->dir_temp; + + dol_mkdir($conf->produit->dir_temp); + + + // If CUSTOMER contact defined on stock, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='stock_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->produit->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + $object->fetch_optionals(); + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); + $array_user=$this->get_substitutionarray_user($user,$outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in stock as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/',$key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + } + } + // Replace tags of lines + try + { + $listlines = $odfHandler->setSegment('supplierprices'); + if(!empty($object->supplierprices)){ + foreach ($object->supplierprices as $supplierprice) + { + $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); + complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($array_lines as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + } + $odfHandler->mergeSegment($listlines); + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } + + // Call the beforeODTSave hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + return -1; + } + +} + diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php new file mode 100644 index 00000000000..5825bd693f5 --- /dev/null +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -0,0 +1,1158 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/stock/doc/pdf_standard.modules.php + * \ingroup societe + * \brief File of class to build PDF documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class pdf_standard extends ModelePDFStock +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.3 = array(5, 3) + */ + public $phpmin = array(5, 2); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + public $page_largeur; + public $page_hauteur; + public $format; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $emetteur; // Objet societe qui emet + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "standard"; + $this->description = $langs->trans("DocumentModelStandardPDF"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Define position of columns + $this->wref = 15; + $this->posxdesc=$this->marge_gauche+1; + $this->posxlabel=$this->posxdesc+$this->wref; + $this->posxtva=80; + $this->posxqty=95; + $this->posxup=115; + $this->posxunit=135; + $this->posxdiscount=155; + $this->postotalht=175; + + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->posxunit-=20; + $this->posxdiscount-=20; + $this->postotalht-=20; + } + $this->tva=array(); + $this->localtax1=array(); + $this->localtax2=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } + + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$db,$hookmanager; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("stocks"); + $outputlangs->load("orders"); + $outputlangs->load("deliveries"); + + $nblignes = count($object->lines); + + if ($conf->stock->dir_output) + { + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->stock->dir_output; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->stock->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + $stockFournisseur = new ProductFournisseur($this->db); + $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $productstatic=new Product($db); + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1,0); + + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Stock")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle)); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 42; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 130; + $tab_height_newpage = 150; + + /* ************************************************************************** */ + /* */ + /* Affichage de la liste des produits de l'entrepot */ + /* */ + /* ************************************************************************** */ + + $nexY+=5; + $nexY = $pdf->GetY(); + $nexY+=10; + + $totalunit=0; + $totalvalue=$totalvaluesell=0; + + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; + $sql.= " ps.reel as value"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; + $sql.= " WHERE ps.fk_product = p.rowid"; + $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) + $sql.= " AND ps.fk_entrepot = ".$object->id; + $sql.= $db->order($sortfield,$sortorder); + + //dol_syslog('List products', LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $nblignes = $num; + for ($i = 0 ; $i < $nblignes ; $i++) + { + $objp = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->produit = $objtp->label; + } + } + + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of product line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + $productstatic->id=$objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->label = $objp->produit; + $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + + // Label + $pdf->SetXY($this->posxlabel+0.8, $curY); + $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 3, $objp->produit, 0, 'L'); + + // Quantity + $valtoshow=price2num($objp->value, 'MS'); + $towrite = (empty($valtoshow)?'0':$valtoshow); + + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R'); + + $totalunit+=$objp->value; + + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, price(price2num($objp->ppmp,'MU'), 0, $outputlangs), 0, 'R'); + + // Total PMP + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($objp->ppmp*$objp->value,'MT'), 0, $outputlangs), 0, 'R'); + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); + + // Price sell min + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pricemin=$objp->price; + $pdf->SetXY($this->posxdiscount, $curY); + $pdf->MultiCell($this->postotalht-$this->posxdiscount, 3, price(price2num($pricemin,'MU'), 0, $outputlangs), 0, 'R', 0); + + // Total sell min + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($pricemin*$objp->value,'MT'), 0, $outputlangs), 0, 'R', 0); + } + $totalvaluesell+=price2num($pricemin*$objp->value,'MT'); + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + + $db->free($resql); + + /** + * footer table + */ + $nexY = $pdf->GetY(); + $nexY+=2; + $curY = $nexY; + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>0)); + + $pdf->SetFont('','B',$default_font_size-1); + $pdf->SetTextColor(0,0,120); + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->wref, 3, $langs->trans("Total"), 0, 'L'); + + // Quantity + $valtoshow=price2num($totalunit, 'MS'); + $towrite = empty($valtoshow)?'0':$valtoshow; + + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R'); + + // Total PMP + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($totalvalue,'MT'), 0, $outputlangs), 0, 'R'); + + // Price sell min + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + // Total sell min + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($totalvaluesell,'MT'), 0, $outputlangs), 0, 'R', 0); + } + } + else + { + dol_print_error($db); + } + + if ($notetoshow) + { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + + $tab_top = 88; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + // Loop on each lines + /* + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of stock line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // VAT Rate + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) + { + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxtva, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + } + + // Unit price before discount + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + + // Quantity + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxqty, $curY); + // Enough for 6 chars + if($conf->global->PRODUCT_USE_UNITS) + { + $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); + } + else + { + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); + } + + // Unit + if($conf->global->PRODUCT_USE_UNITS) + { + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + } + + // Discount on line + $pdf->SetXY($this->posxdiscount, $curY); + if ($object->lines[$i]->remise_percent) + { + $pdf->SetXY($this->posxdiscount-2, $curY); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + } + + // Total HT line + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + else $tvaligne=$object->lines[$i]->total_tva; + + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; + $localtax1_rate=$object->lines[$i]->localtax1_tx; + $localtax2_rate=$object->lines[$i]->localtax2_tx; + $localtax1_type=$object->lines[$i]->localtax1_type; + $localtax2_type=$object->lines[$i]->localtax2_type; + + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + + $vatrate=(string) $object->lines[$i]->tva_tx; + + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } + + // retrieve global local tax + if ($localtax1_type && $localtax1ligne != 0) + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + if ($localtax2_type && $localtax2ligne != 0) + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + $this->tva[$vatrate] += $tvaligne; + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + */ + $tab_top = $tab_top_newpage+21; + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + + // Affiche zone infos + //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Pied de page + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $this->result = array('fullpath'=>$file); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR"); + return 0; + } + } + + + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom=0; + if ($hidetop) $hidetop=-1; + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + + $pdf->SetDrawColor(128,128,128); + $pdf->SetFont('','B', $default_font_size - 3); + + // Output Rect + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetDrawColor(220,26,26); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->SetLineStyle(array('dash'=>0)); + $pdf->SetDrawColor(128,128,128); + $pdf->SetTextColor(0,0,120); + + if (empty($hidetop)) + { + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->MultiCell($this->wref,3, $outputlangs->transnoentities("Ref"),'','L'); + } + + //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxlabel-3, $tab_top+1); + $pdf->MultiCell($this->posxqty-$this->posxlabel+3,2, $outputlangs->transnoentities("Label"),'','C'); + } + + //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty-1, $tab_top+1); + $pdf->MultiCell($this->posxup-$this->posxqty-1,2, $outputlangs->transnoentities("Units"),'','C'); + } + + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup-1, $tab_top+1); + $pdf->MultiCell($this->posxunit-$this->posxup-1,2, $outputlangs->transnoentities("AverageUnitPricePMPShort"),'','C'); + } + + //$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', + 'C'); + } + + //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("SellPriceMin"),'','C'); + } + + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("EstimatedStockValueSellShort"),'','C'); + } + + $pdf->SetDrawColor(220,26,26); + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>0)); + + } + + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @param string $titlekey Translation key to show as title of document + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") + { + global $conf,$langs,$db,$hookmanager; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + $outputlangs->load("orders"); + $outputlangs->load("stocks"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + if ($object->type == 1) $titlekey='ServiceSheet'; + else $titlekey='StockSheet'; + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + // Show Draft Watermark + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + $posx=$this->page_largeur-$this->marge_droite-100; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("Warehouse"); + $pdf->MultiCell(100, 3, $title, '', 'R'); + + $pdf->SetFont('','B',$default_font_size); + + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R'); + + $posy+=5; + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $pdf->MultiCell(150, 3, $object->lieu, '', 'R'); + + + // Parent entrepot + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $e = new Entrepot($db); + if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) + { + $pdf->MultiCell(150, 3, $e->libelle, '', 'R'); + } + else + { + $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R'); + } + + // Description + $nexY = $pdf->GetY(); + $nexY+=5; + $pdf->SetXY($posx,$posy); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); + $nexY = $pdf->GetY(); + + $calcproductsunique=$object->nb_different_products(); + $calcproducts=$object->nb_products(); + + // Total nb of different products + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $nexY = $pdf->GetY(); + + // Nb of products + $valtoshow=price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $nexY = $pdf->GetY(); + + // Value + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $nexY = $pdf->GetY(); + + + // Last movement + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate=$db->jdate($obj->datem); + } + else + { + dol_print_error($db); + } + + if ($lastmovementdate) + { + $toWrite = dol_print_date($lastmovementdate,'dayhour').' '; + } + else + { + $toWrite = $outputlangs->transnoentities("None"); + } + + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("LastMovement").' : '.$toWrite, 0, 1); + $nexY = $pdf->GetY(); + + + /*if ($object->ref_client) + { + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + }*/ + + /*$posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); + */ + + // Get contact + /* + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) + { + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $usertmp=new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + } + }*/ + + $posy+=2; + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + } + + $pdf->SetTextColor(0,0,0); + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php new file mode 100644 index 00000000000..16d979d60ee --- /dev/null +++ b/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php @@ -0,0 +1,1159 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/stock/doc/pdf_standard.modules.php + * \ingroup societe + * \brief File of class to build PDF documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class pdf_stdmouvement extends ModelePDFMouvement +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.3 = array(5, 3) + */ + public $phpmin = array(5, 2); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + public $page_largeur; + public $page_hauteur; + public $format; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $emetteur; // Objet societe qui emet + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "stdmouvement"; + $this->description = $langs->trans("DocumentModelStandardPDF"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Define position of columns + $this->wref = 15; + $this->posxidref = $this->marge_gauche; + $this->posxdatemouv = $this->marge_gauche+8;; + $this->posxdesc=37; + $this->posxlabel=50; + $this->posxtva=80; + $this->posxqty=105; + $this->posxup=119; + $this->posxunit=136; + $this->posxdiscount=167; + $this->postotalht=180; + + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->posxunit-=20; + $this->posxdiscount-=20; + $this->postotalht-=20; + } + $this->tva=array(); + $this->localtax1=array(); + $this->localtax2=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } + + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$db,$hookmanager; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("stocks"); + $outputlangs->load("orders"); + $outputlangs->load("deliveries"); + + /** + * TODO: get from object + */ + + $id=GETPOST('id','int'); + $ref = GETPOST('ref','alpha'); + $msid=GETPOST('msid','int'); + $product_id=GETPOST("product_id"); + $action=GETPOST('action','aZ09'); + $cancel=GETPOST('cancel','alpha'); + $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; + + $idproduct = GETPOST('idproduct','int'); + $year = GETPOST("year"); + $month = GETPOST("month"); + $search_ref = GETPOST('search_ref', 'alpha'); + $search_movement = GETPOST("search_movement"); + $search_product_ref = trim(GETPOST("search_product_ref")); + $search_product = trim(GETPOST("search_product")); + $search_warehouse = trim(GETPOST("search_warehouse")); + $search_inventorycode = trim(GETPOST("search_inventorycode")); + $search_user = trim(GETPOST("search_user")); + $search_batch = trim(GETPOST("search_batch")); + $search_qty = trim(GETPOST("search_qty")); + $search_type_mouvement=GETPOST('search_type_mouvement','int'); + + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; + $page = GETPOST("page",'int'); + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + $offset = $limit * $page; + if (! $sortfield) $sortfield="m.datem"; + if (! $sortorder) $sortorder="DESC"; + + $pdluoid=GETPOST('pdluoid','int'); + + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('movementlist')); + $extrafields = new ExtraFields($db); + + // fetch optionals attributes and labels + $extralabels = $extrafields->fetch_name_optionals_label('movement'); + $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + + $productlot=new ProductLot($db); + $productstatic=new Product($db); + $warehousestatic=new Entrepot($db); + $movement=new MouvementStock($db); + $userstatic=new User($db); + + $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; + $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; + $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; + $sql.= " m.batch, m.price,"; + $sql.= " m.type_mouvement,"; + $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; + $sql.= " u.login, u.photo, u.lastname, u.firstname"; + // Add fields from extrafields + foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + // 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."entrepot as e,"; + $sql.= " ".MAIN_DB_PREFIX."product as p,"; + $sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m"; + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; + $sql.= " WHERE m.fk_product = p.rowid"; + if ($msid > 0) $sql .= " AND m.rowid = ".$msid; + $sql.= " AND m.fk_entrepot = e.rowid"; + $sql.= " AND e.entity IN (".getEntity('stock').")"; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; + if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; + if ($month > 0) + { + if ($year > 0) + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else + $sql.= " AND date_format(m.datem, '%m') = '$month'"; + } + else if ($year > 0) + { + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; + if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); + if (! empty($search_movement)) $sql.= natural_search('m.label', $search_movement); + if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode); + if (! empty($search_product_ref)) $sql.= natural_search('p.ref', $search_product_ref); + if (! empty($search_product)) $sql.= natural_search('p.label', $search_product); + if ($search_warehouse > 0) $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'"; + if (! empty($search_user)) $sql.= natural_search('u.login', $search_user); + if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch); + if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1); + if ($search_type_mouvement > 0) $sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'"; + // Add where from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + // 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); + + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } + } + + if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset); + + + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + /* + * END TODO + **/ + + //$nblignes = count($object->lines); + + if ($conf->stock->dir_output) + { + + if ($resql) + { + $product = new Product($db); + $object = new Entrepot($db); + + if ($idproduct > 0) + { + $product->fetch($idproduct); + } + if ($id > 0 || $ref) + { + $result = $object->fetch($id, $ref); + if ($result < 0) + { + dol_print_error($db); + } + } + + $num = $db->num_rows($resql); + + $arrayofselected=is_array($toselect)?$toselect:array(); + + $i = 0; + $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + if ($msid) $texte = $langs->trans('StockMovementForId', $msid); + else + { + $texte = $langs->trans("ListOfStockMovements"); + if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + } + } + + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->stock->dir_output . "/mouvement"; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; + if($search_type_mouvement) $objectref.="_".$search_type_mouvement; + $dir = $conf->stock->dir_output . "/mouvement/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + $stockFournisseur = new ProductFournisseur($this->db); + $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $productstatic=new Product($db); + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1,0); + + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Stock")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle)); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 42; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 130; + $tab_height_newpage = 150; + + /* ************************************************************************** */ + /* */ + /* Affichage de la liste des produits du MouvementStock */ + /* */ + /* ************************************************************************** */ + + $nexY+=5; + $nexY = $pdf->GetY(); + $nexY+=10; + + $totalunit=0; + $totalvalue=$totalvaluesell=0; + + //dol_syslog('List products', LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $nblignes = $num; + for ($i = 0 ; $i < $nblignes ; $i++) + { + $objp = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->produit = $objtp->label; + } + } + + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of product line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // $objp = $db->fetch_object($resql); + + $userstatic->id=$objp->fk_user_author; + $userstatic->login=$objp->login; + $userstatic->lastname=$objp->lastname; + $userstatic->firstname=$objp->firstname; + $userstatic->photo=$objp->photo; + + $productstatic->id=$objp->rowid; + $productstatic->ref=$objp->product_ref; + $productstatic->label=$objp->produit; + $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; + + $productlot->id = $objp->lotid; + $productlot->batch= $objp->batch; + $productlot->eatby= $objp->eatby; + $productlot->sellby= $objp->sellby; + + $warehousestatic->id=$objp->entrepot_id; + $warehousestatic->libelle=$objp->stock; + $warehousestatic->lieu=$objp->lieu; + + $arrayofuniqueproduct[$objp->rowid]=$objp->produit; + if(!empty($objp->fk_origin)) { + $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); + } else { + $origin = ''; + } + + // Id movement. + $pdf->SetXY($this->posxidref, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L'); + + // Date. + $pdf->SetXY($this->posxdatemouv, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L'); + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L'); + + // Label + $pdf->SetXY($this->posxlabel+0.8, $curY); + $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L'); + + // Lot/serie + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R'); + + // Inv. code + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R'); + + // Label mouvement + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R'); + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); + + // Origin + $pricemin=$objp->price; + $pdf->SetXY($this->posxdiscount, $curY); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0); + + // Qty + $valtoshow=price2num($objp->qty, 'MS'); + $towrite = (empty($valtoshow)?'0':$valtoshow); + $totalunit+=$objp->qty; + + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0); + + $totalvaluesell+=price2num($pricemin*$objp->value,'MT'); + + $nexY+=3.5; // Passe espace entre les lignes + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + + $db->free($resql); + + /** + * footer table + */ + $nexY = $pdf->GetY(); + $nexY+=5; + $curY = $nexY; + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>0)); + + $pdf->SetFont('','B',$default_font_size-1); + $pdf->SetTextColor(0,0,120); + + // Total + $pdf->SetXY($this->posxidref, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L'); + + // Total Qty + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0); + + } + else + { + dol_print_error($db); + } + + if ($notetoshow) + { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + + $tab_top = 88; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + $tab_top = $tab_top_newpage+21; + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + + // Affiche zone infos + //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Pied de page + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $this->result = array('fullpath'=>$file); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR"); + return 0; + } + } + + + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom=0; + if ($hidetop) $hidetop=-1; + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + + $pdf->SetDrawColor(128,128,128); + $pdf->SetFont('','B', $default_font_size - 3); + + // Output Rect + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetDrawColor(220,26,26); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->SetLineStyle(array('dash'=>0)); + $pdf->SetDrawColor(128,128,128); + $pdf->SetTextColor(0,0,120); + + //Ref mouv + if (empty($hidetop)) + { + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->SetXY($this->posxidref, $tab_top+1); + $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L'); + } + + //Date mouv + //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdatemouv, $tab_top+1); + $pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C'); + } + + //Ref Product + //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C'); + } + + //Label Product + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxlabel-1, $tab_top+1); + $pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C'); + } + + //Lot/serie Product + //$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C'); + } + + //Code Inv + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup-1, $tab_top+1); + $pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C'); + } + + //Label mouvement + //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxunit, $tab_top+1); + $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C'); + } + + //Origin + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdiscount+2, $tab_top+1); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C'); + } + + //Qty + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht+2, $tab_top+1); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C'); + } + + $pdf->SetDrawColor(220,26,26); + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>0)); + + } + + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @param string $titlekey Translation key to show as title of document + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") + { + global $conf,$langs,$db,$hookmanager; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + $outputlangs->load("orders"); + $outputlangs->load("stocks"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + if ($object->type == 1) $titlekey='ServiceSheet'; + else $titlekey='StockSheet'; + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + // Show Draft Watermark + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + $posx=$this->page_largeur-$this->marge_droite-100; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("Warehouse"); + $pdf->MultiCell(100, 3, $title, '', 'R'); + + $pdf->SetFont('','B',$default_font_size); + + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R'); + + $posy+=5; + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $pdf->MultiCell(150, 3, $object->lieu, '', 'R'); + + + // Parent MouvementStock + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $e = new MouvementStock($db); + if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) + { + $pdf->MultiCell(150, 3, $e->libelle, '', 'R'); + } + else + { + $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R'); + } + + // Description + $nexY = $pdf->GetY(); + $nexY+=5; + $pdf->SetXY($posx,$posy); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); + $nexY = $pdf->GetY(); + + $calcproductsunique=$object->nb_different_products(); + $calcproducts=$object->nb_products(); + + // Total nb of different products + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $nexY = $pdf->GetY(); + + // Nb of products + $valtoshow=price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $nexY = $pdf->GetY(); + + // Value + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $nexY = $pdf->GetY(); + + + // Last movement + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate=$db->jdate($obj->datem); + } + else + { + dol_print_error($db); + } + + if ($lastmovementdate) + { + $toWrite = dol_print_date($lastmovementdate,'dayhour').' '; + } + else + { + $toWrite = $outputlangs->transnoentities("None"); + } + + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("LastMovement").' : '.$toWrite, 0, 1); + $nexY = $pdf->GetY(); + + + /*if ($object->ref_client) + { + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + }*/ + + /*$posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); + */ + + // Get contact + /* + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) + { + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $usertmp=new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + } + }*/ + + $posy+=2; + + // Show list of linked objects + //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + } + + $pdf->SetTextColor(0,0,0); + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/stock/modules_stock.class.php b/htdocs/core/modules/stock/modules_stock.class.php new file mode 100644 index 00000000000..9af3aa11501 --- /dev/null +++ b/htdocs/core/modules/stock/modules_stock.class.php @@ -0,0 +1,90 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + + +/** + * \class ModeleStock + * \brief Parent class for warehouse generators + */ + +/** + * \file htdocs/core/modules/stock/modules_stock.php + * \ingroup stock + * \brief File with parent class for generating warehouse to PDF and File of class to manage warehouse mouvement + */ + + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +/** + * Parent class to manage warehouse document templates + */ +abstract class ModelePDFStock extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='stock'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + return $liste; + } +} + + +/** + * Parent class to manage warehouse mouvement document templates + */ +abstract class ModelePDFMouvement extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='mouvementcom'; + $liste=array(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + return $liste; + } +} \ No newline at end of file diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php new file mode 100644 index 00000000000..f1c72601b97 --- /dev/null +++ b/htdocs/core/modules/stock/modules_stock.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2016 Charlie Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +/** + * \class ModeleStock + * \brief Parent class for stock models of doc generators + */ +abstract class ModeleStock extends CommonDocGenerator +{ + var $error=''; + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='stock'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} From bc7b05537f6f41f1707a0c00f027ec768d4aaf9b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 3 May 2018 09:26:48 +0200 Subject: [PATCH 047/183] NEW: hidden conf to assign category to thirparty neither customer nor prospect nor supplier --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 204eff383d5..afec096a500 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1321,7 +1321,7 @@ else $langs->load('categories'); // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, @@ -1879,7 +1879,7 @@ else if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); @@ -2269,7 +2269,7 @@ else if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . $langs->trans("CustomersCategoriesShort") . ''; print $form->showCategories($object->id, 'customer', 1); From f70df3490feb344fe59dfbb6afafac0e2c06299e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 3 May 2018 10:53:24 +0200 Subject: [PATCH 048/183] FIX add db commit --- htdocs/core/actions_massactions.inc.php | 40 +++++++++++++++++++++++-- htdocs/langs/fr_FR/errors.lang | 1 + 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 6303d78d6ef..c2c3467e55c 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -736,8 +736,14 @@ if ($massaction == 'confirm_createbills') } } -if ($massaction == 'cancelorders') +if (!$error && $massaction == 'cancelorders') { + + $db->begin(); + + $nbok = 0; + + $orders = GETPOST('toselect', 'array'); foreach ($orders as $id_order) { @@ -745,7 +751,37 @@ if ($massaction == 'cancelorders') $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) continue; - $cmd->cancel(); + + if ($cmd->statut != Commande::STATUS_VALIDATED) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); + $error++; + break; + } + else + $result = $cmd->cancel(); + + if ($result < 0) + { + setEventMessages($cmd->error, $cmd->errors, 'errors'); + $error++; + break; + } + else + $nbok++; + } + if (!$error) + { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); } } diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index c6fe1334436..c3c3f55deb4 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -208,6 +208,7 @@ ErrorFileNotFoundWithSharedLink=Fichier non trouvé. Peut que la clé de partage ErrorProductBarCodeAlreadyExists=Le code-barre du produit %s existe déjà sur une autre référence de produit ErrorNoteAlsoThatSubProductCantBeFollowedByLot=Notez également que l'utilisation d'un produit virtuel pour augmenter ou réduire automatiquement les sous-produits n'est pas possible lorsqu'au moins un sous-produit (ou sous-produit de sous-produits) a besoin d'un numéro de série/lot. ErrorDescRequiredForFreeProductLines=La description est obligatoire pour les lignes avec un produit non prédéfini +ErrorObjectMustHaveStatusValidToBeCanceled=L'objet %s doit être au statut 'Validé' pour être annulé # Warnings WarningPasswordSetWithNoAccount=Un mot de passe a été fixé pour cet adhérent. Cependant, aucun compte d'utilisateur n'a été créé. Donc, ce mot de passe est stocké, mais ne peut être utilisé pour accéder à Dolibarr. Il peut être utilisé par un module/interface externe, mais si vous n'avez pas besoin de définir ni login ni mot de passe pour un adhérent, vous pouvez désactiver l'option «Gérer un login pour chaque adhérent" depuis la configuration du module Adhérents. Si vous avez besoin de gérer un login, mais pas de mot de passe, vous pouvez laisser ce champ vide pour éviter cet avertissement. Remarque: L'email peut également être utilisé comme login si l'adhérent est lié à un utilisateur. From 6245f25deb85cc0ef6cdb92e89ff64fb72e54d79 Mon Sep 17 00:00:00 2001 From: atm-arnaud Date: Thu, 3 May 2018 11:45:41 +0200 Subject: [PATCH 049/183] FIX label in getnomurl projectlist --- htdocs/projet/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6eaf231a5cb..dc3ab9a58ac 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -668,6 +668,7 @@ while ($i < min($num,$limit)) $object->datee = $db->jdate($obj->date_end); $object->statut = $obj->fk_statut; $object->opp_status = $obj->fk_opp_status; + $object->title = $obj->title; $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) From 08cf034e2f35db1ce6cc5e40e6e25606f6948426 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 May 2018 13:39:44 +0200 Subject: [PATCH 050/183] FIX to allow IRPF not null even if main VAT is null. From https://www.javierrguez.com/problema-facturas-irpf-sin-iva-dolibarr/ --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a22a9675ff6..78010725086 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4261,7 +4261,8 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller if ($local == 2) { - if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; + //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; + if (! $mysoc->localtax2_assuj) return 0; // If main vat is 0, IRPF may be different than 0. if ($thirdparty_seller->id == $mysoc->id) { if (! $thirdparty_buyer->localtax2_assuj) return 0; From f3a70a40d7b12cd921edddcf45f03c09c71fbd00 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 3 May 2018 21:27:52 +0200 Subject: [PATCH 051/183] clean and update code --- htdocs/admin/expedition.php | 8 +++---- htdocs/admin/livraison.php | 14 ++++------- htdocs/admin/mailing.php | 9 ++----- htdocs/admin/mailman.php | 10 +++----- htdocs/admin/mails.php | 40 ++++---------------------------- htdocs/admin/mails_emailing.php | 12 ---------- htdocs/admin/mails_templates.php | 6 +---- 7 files changed, 17 insertions(+), 82 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 442a85c9c6a..311398a78e1 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -6,7 +6,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (! $user->admin) accessforbidden(); diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 4c18069b415..0af26a0a2b7 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -6,8 +6,8 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2015 Claudio Aschieri * * 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 @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (!$user->admin) accessforbidden(); @@ -216,7 +214,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -337,7 +334,6 @@ print "
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print ''; print ''; print ''; print "\n"; - print ''; - print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $langs->trans("MailingEMailFrom").''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingEMailError").''; print ''; if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingDelay").''; print ''; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 89416a72e36..bb53349d1b7 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -32,9 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("admin"); -$langs->load("members"); -$langs->load("mailmanspip"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "members", "mailmanspip")); if (! $user->admin) accessforbidden(); @@ -49,7 +48,7 @@ $testunsubscribeemail = GETPOST("testunsubscribeemail"); * Actions */ -// Action mise a jour ou ajout d'une constante +// Action updated or added a constant if ($action == 'update' || $action == 'add') { foreach($_POST['constname'] as $key => $val) @@ -156,9 +155,6 @@ print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup' $head = mailmanspip_admin_prepare_head(); - -$var=true; - if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index f85853f5b97..f4c5a2531ff 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -27,12 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("mails"); -$langs->load("other"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors")); $action=GETPOST('action','alpha'); @@ -260,13 +256,11 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; // Disable - print ''; @@ -283,11 +277,9 @@ if ($action == 'edit') print ''; // Separator - print ''; // Method - print ''; // Port - print ''; // From - print ''; print ''; @@ -497,22 +486,19 @@ if ($action == 'edit') } else dol_print_error($db);*/ - print ''; // Separator - print ''; // From - print ''; print ''; // Autocopy to - print ''; print ''; @@ -535,15 +521,11 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - - $var=true; - + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''; print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print '
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; // SuperAdministrator access only @@ -338,7 +330,6 @@ if ($action == 'edit') print '
'; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { @@ -411,7 +402,6 @@ if ($action == 'edit') } // TLS - print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { @@ -469,7 +459,6 @@ if ($action == 'edit') print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0); print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").'
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'
'; print ''; // Disable - print ''; // Force e-mail recipient @@ -555,11 +537,9 @@ else print ''; // Separator - print ''; // Method - print ''; // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -578,7 +557,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -589,21 +567,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print ''; // From - print ''; print ''; // Separator - print ''; // Errors To - print ''; print ''; // Autocopy to - print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -567,7 +547,6 @@ else print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -617,7 +592,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -634,7 +608,6 @@ else if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') { // DKIM - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) { @@ -664,11 +637,9 @@ else } // Separator - print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); @@ -723,18 +694,15 @@ else print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print '
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 1202e9817d3..1cb92ae8377 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -228,7 +228,6 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; @@ -341,7 +340,6 @@ if ($action == 'edit') // PW if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING:''); print ''; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8eb6f0b98c8..a8798901a21 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -822,6 +822,9 @@ select.flat.selectlimit { .fa-trash, .fa-crop, .fa-pencil { font-size: 1.4em; } +.fa-15 { + font-size: 1.5em; +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { From b5f222f45aca791b65de2264c314fad190318dae Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 4 May 2018 14:14:04 +0200 Subject: [PATCH 054/183] Clean and update code --- htdocs/admin/menus.php | 7 ------- htdocs/admin/payment.php | 9 ++------- htdocs/admin/prelevement.php | 1 - htdocs/admin/propal.php | 13 ++++--------- htdocs/admin/proxy.php | 15 ++++++--------- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 7ffaa9a110a..a5f2fb2a2ff 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -163,8 +163,6 @@ if ($action == 'edit') clearstatcache(); // Gestionnaires de menu - $var=true; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only @@ -405,14 +403,10 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - $var=true; - print ''; print ''; // Method - print ''; @@ -433,7 +426,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print ''; @@ -444,21 +436,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -422,7 +416,6 @@ else if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { @@ -472,7 +461,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 4e731021199..60db9fae8c4 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -447,7 +447,6 @@ $fieldlist=explode(',',$tabfield[$id]); // Form to add a new line $alabelisused=0; -$var=false; print ''; print ''; @@ -591,9 +590,7 @@ $colspan=count($fieldlist)+1; print '
'; print ''; - print ''; - print '
'; @@ -611,7 +608,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; $paramwithsearch = $param; From 1f775c907dfd22f73ca75f54a561e08a206a177f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 11:01:22 +0200 Subject: [PATCH 052/183] Fix translation of % column in gantt view --- dev/dolibarr_changes.txt | 8 ++++++++ htdocs/includes/jsgantt/jsgantt.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 9e6ab3a8ddc..cdbc2e2bb40 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -90,6 +90,14 @@ var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); vTmpNode.setAttribute('href',vTaskList[i].getLink()); +* Replace '% Comp.' to have a smaller text column header +'comp':'% Comp.' +with +'comp':'%' + + + + JCROP: ------ diff --git a/htdocs/includes/jsgantt/jsgantt.js b/htdocs/includes/jsgantt/jsgantt.js index 7a26eecb9fc..04921b92405 100644 --- a/htdocs/includes/jsgantt/jsgantt.js +++ b/htdocs/includes/jsgantt/jsgantt.js @@ -331,7 +331,7 @@ JSGantt.GanttChart=function(pDiv, pFormat) var vLangs={'en': {'format':'Format','hour':'Hour','day':'Day','week':'Week','month':'Month','quarter':'Quarter','hours':'Hours','days':'Days', 'weeks':'Weeks','months':'Months','quarters':'Quarters','hr':'Hr','dy':'Day','wk':'Wk','mth':'Mth','qtr':'Qtr','hrs':'Hrs', - 'dys':'Days','wks':'Wks','mths':'Mths','qtrs':'Qtrs','resource':'Resource','duration':'Duration','comp':'% Comp.', + 'dys':'Days','wks':'Wks','mths':'Mths','qtrs':'Qtrs','resource':'Resource','duration':'Duration','comp':'%', 'completion':'Completion','startdate':'Start Date','enddate':'End Date','moreinfo':'More Information','notes':'Notes', 'january':'January','february':'February','march':'March','april':'April','maylong':'May','june':'June','july':'July', 'august':'August','september':'September','october':'October','november':'November','december':'December','jan':'Jan', From 5cff4c152b28441ddfd04329804b12cde4dddcef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 11:25:21 +0200 Subject: [PATCH 053/183] Add tab "time spent" in project view. Can swith gantt/list. --- htdocs/core/lib/project.lib.php | 8 +++--- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/ganttview.php | 42 ++++++++++++-------------------- htdocs/projet/tasks.php | 5 ++-- htdocs/projet/tasks/time.php | 11 +++++---- htdocs/theme/eldy/style.css.php | 3 +++ 6 files changed, 32 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 06d0b7aa6d3..6a8ef760a04 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -104,10 +104,10 @@ function project_prepare_head($object) $head[$h][2] = 'tasks'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id; - $head[$h][1] = $langs->trans("Gantt"); - if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; - $head[$h][2] = 'gantt'; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; + $head[$h][1] = $langs->trans("TimeSpent"); + //if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; + $head[$h][2] = 'timespent'; $h++; } diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 85937ad827a..6dfb11e2284 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -77,6 +77,7 @@ Time=Time ListOfTasks=List of tasks GoToListOfTimeConsumed=Go to list of time consumed GoToListOfTasks=Go to list of tasks +GoToGanttView=Go to Gantt view GanttView=Gantt View ListProposalsAssociatedProject=List of the commercial proposals associated with the project ListOrdersAssociatedProject=List of customer orders associated with the project diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 0c1e86c8ab5..248eb1a63b3 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -80,7 +80,8 @@ if (! empty($conf->use_javascript_ajax)) ); } -$title=$langs->trans("Project").' - '.$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); +//$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); +$title=$langs->trans("Gantt"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$title,$help_url,'',0,0,$arrayofjs,$arrayofcss); @@ -93,7 +94,7 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab='gantt'; + $tab='tasks'; $head=project_prepare_head($object); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); @@ -187,43 +188,32 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) print '
'; dol_fiche_end(); + + print '
'; } - -/* - * Buttons actions - */ - -if ($id > 0 && is_numeric($id)) +// Link to create task +if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - - print '
'; - - if ($user->rights->projet->all->creer || $user->rights->projet->creer) + if ($object->public || $userWrite > 0) { - if ($object->public || $userWrite > 0) - { - print ''.$langs->trans('AddTask').''; - } - else - { - print ''.$langs->trans('AddTask').''; - } + $linktocreatetask = ''.$langs->trans('AddTask').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } - - print '
'; - - print '
'; } else { - print_fiche_titre($langs->trans("GanttView")); + $linktocreatetask = ''.$langs->trans('AddTask').''; } +$linktolist=''.$langs->trans("GoToListOfTasks").' '; + +//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); +print load_fiche_titre($title, $linktolist.'   '.$linktocreatetask, 'title_generic.png'); + // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 67dd84a1572..22fe740a63b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("users"); -$langs->load("projects"); +$langs->loadLangs(array("users", "projects")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -489,7 +488,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $title=$langs->trans("ListOfTasks"); - $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; + $linktotasks=''.$langs->trans("GoToGanttView").' '; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 0f2ec5f9fcd..86a2027b3b7 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -320,7 +320,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($withproject) { // Tabs for project - $tab='tasks'; + if (empty($id)) $tab='timespent'; + else $tab='tasks'; $head=project_prepare_head($projectstatic); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); @@ -695,9 +696,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''."\n"; $title=$langs->trans("ListTaskTimeUserProject"); - $linktotasks=''.$langs->trans("GoToListOfTasks").''; + //$linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime, 'title_generic.png'); + print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); } $i = 0; @@ -868,8 +869,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.task_date']['checked'])) { print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_year,'search_year',1, 20, 5); print '
'; print ''; print ''; // Menu top - print ''; print ''; // Menu smartphone - print ''; print '
'.$langs->trans("Menu").''; @@ -176,7 +174,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled'); @@ -187,7 +184,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuSmartphoneManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled'); @@ -202,8 +198,6 @@ if ($action == 'edit') else { // Gestionnaires de menu - $var=true; - print ''; print ''; print ''; print "\n"; // Allow payments on different thirdparties bills but same parent company -$var=! $var; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index c533ea94795..7ee44a93b52 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -33,10 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('propal'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "propal")); if (! $user->admin) accessforbidden(); @@ -266,8 +265,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -386,7 +383,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -531,7 +527,6 @@ print ''; print ''; /* -$var=! $var; print ''; print ''; print ''; @@ -631,7 +626,7 @@ print "\n"; print " \n"; print " \n"; print "\n"; -print "\n \n \n\n"; +print "\n \n \n\n"; print "
'.$langs->trans("Menu").''; @@ -267,7 +261,6 @@ if ($action == 'edit') print ''; - if ($action != 'edit') { print '
'; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 339b4fef566..4fe15379629 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -26,10 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('bills'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "bills")); if (! $user->admin) accessforbidden(); @@ -131,8 +129,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -249,7 +245,6 @@ print '
 
'; print $langs->trans("PaymentOnDifferentThirdBills"); print ''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 21f34f2a770..203b4ed9bc5 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -274,7 +274,6 @@ print "
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
\n
"; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index ee22f377200..a9028635991 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -26,10 +26,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); - +// Load traductions files requiredby by page +$langs->loadLangs(array("other", "users", "admin")); if (!$user->admin) accessforbidden(); @@ -124,7 +122,6 @@ if ($conf->use_javascript_ajax) // Timeout -$var=true; print ''; @@ -163,7 +160,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; + print ''; + } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + print ''; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; } if (! empty($arrayfields['p.total_ht']['checked'])) { @@ -644,6 +714,8 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'],$_SERVER["PHP_SELF"],'ddelivery','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'],$_SERVER["PHP_SELF"],'availability','',$param, '',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder); @@ -809,6 +881,28 @@ if ($resql) } if (! $i) $totalarray['nbfield']++; } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + if ($obj->ddelivery) + { + print ''; + } + else + { + print ''; + } + if (! $i) $totalarray['nbfield']++; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Amount HT if (! empty($arrayfields['p.total_ht']['checked'])) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c02ada175fd..fa606639bcc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -2903,7 +2904,7 @@ class Form dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); - print ''; if ($addempty) print ''; foreach($this->cache_availability as $id => $arrayavailability) { From e62426546dbf6ea3316d4e31dd107dcdbd841553 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 9 May 2018 15:02:46 +0100 Subject: [PATCH 095/183] Add Documents generes --- htdocs/product/stock/card.php | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 4fccbf4622f..eca9086c48a 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -26,6 +26,7 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; @@ -64,6 +65,10 @@ $object = new Entrepot($db); * Actions */ +$usercanread = (($user->rights->stock->lire)); +$usercancreate = (($user->rights->stock->creer)); +$usercandelete = (($user->rights->stock->supprimer)); + // Ajout entrepot if ($action == 'add' && $user->rights->stock->creer) { @@ -164,6 +169,55 @@ if ($cancel == $langs->trans("Cancel")) $action = ''; } +/* + * Build document + */ +if ($action == 'builddoc') // En get ou en post +{ + if ($id > 0 || $ref) + { + $object = new Entrepot($db); + $result = $object->fetch($id, $ref); + if ($result <= 0) + { + print 'No record found'; + exit; + } + } + + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + $result= $object->generateDocument($object->modelpdf, $outputlangs); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } +} + +// Delete file in doc form +elseif ($action == 'remove_file') +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $upload_dir = $conf->stock->dir_output ; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); +} /* @@ -174,6 +228,7 @@ $productstatic=new Product($db); $form=new Form($db); $formproduct=new FormProduct($db); $formcompany=new FormCompany($db); +$formfile = new FormFile($db); $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("",$langs->trans("WarehouseCard"),$help_url); @@ -654,6 +709,47 @@ else } } +/* + * Documents generes + */ + +$modulepart='stock'; + +if ($action != 'create' && $action != 'edit' && $action != 'delete') +{ + print '
'; + print '
'; + print ''; // ancre + + // Documents + $objectref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $objectref . '.pdf'; + $filedir = $conf->stock->dir_output . '/' . $objectref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed=$usercanread; + $delallowed=$usercancreate; + + $var=true; + + print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + $somethingshown=$formfile->numoffiles; + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + + print '
'; +} + llxFooter(); From c0e5132108d24617836d30a27ae5c46af83f8c4e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 9 May 2018 15:07:11 +0100 Subject: [PATCH 096/183] Documents generes movement warehouse --- htdocs/product/stock/mouvement.php | 153 ++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 883cd316c76..edabf9184da 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -26,6 +26,7 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -68,6 +69,7 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); +$search_type_mouvement=GETPOST('search_type_mouvement','int'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); @@ -84,6 +86,7 @@ $pdluoid=GETPOST('pdluoid','int'); $object = new MouvementStock($db); $hookmanager->initHooks(array('movementlist')); $extrafields = new ExtraFields($db); +$formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); @@ -101,6 +104,7 @@ $arrayfields=array( 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("LabelMovement"), 'checked'=>1), + 'm.type_mouvement'=>array('label'=>$langs->trans("Type Mouvement"), 'checked'=>1), 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0), @@ -114,6 +118,10 @@ $arrayfields=array( * Actions */ +$usercanread = (($user->rights->stock->mouvement->lire)); +$usercancreate = (($user->rights->stock->mouvement->creer)); +$usercandelete = (($user->rights->stock->mouvement->supprimer)); + if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } @@ -130,6 +138,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $month=''; $search_ref=''; $search_movement=""; + $search_type_mouvement=""; + $search_inventorycode=""; $search_product_ref=""; $search_product=""; $search_warehouse=""; @@ -389,7 +399,58 @@ if ($action == "transfert_stock" && ! $cancel) } } -if (empty($reshook)) + +/* + * Build document + */ +if ($action == 'builddoc') // En get ou en post +{ + if ($id > 0 || $ref) + { + $object = new MouvementStock($db); + $result = $object->fetch($id, $ref); + if ($result <= 0) + { + print 'No record found'; + exit; + } + } + + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + $result= $object->generateDocument($object->modelpdf, $outputlangs); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } +} + +// Delete file in doc form +elseif ($action == 'remove_file') +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $upload_dir = $conf->stock->dir_output."/mouvement" ; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); +} + +if (empty($reshook) && $action != 'remove_file') { $objectclass='MouvementStock'; $objectlabel='Movements'; @@ -419,6 +480,7 @@ $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.f $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; +$sql.= " m.type_mouvement,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields @@ -460,6 +522,7 @@ if ($search_warehouse > 0) $sql.= " AND e.rowid = '".$db->escape($searc if (! empty($search_user)) $sql.= natural_search('u.login', $search_user); if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1); +if ($search_type_mouvement) $sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -480,11 +543,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +if(empty($search_inventorycode)) +{ + $sql.= $db->plimit($limit+1, $offset); +} +else +{ + $limit = 0; +} //print $sql; $resql = $db->query($sql); + +if(!empty($search_inventorycode)) $limit = $db->num_rows($resql); + if ($resql) { $product = new Product($db); @@ -663,6 +736,7 @@ if ($resql) if ($id > 0) $param.='&id='.$id; if ($search_movement) $param.='&search_movement='.urlencode($search_movement); if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); if ($search_product) $param.='&search_product='.urlencode($search_product); if ($search_batch) $param.='&search_batch='.urlencode($search_batch); @@ -801,6 +875,22 @@ if ($resql) print '
'; + } + if (! empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + print ''; } if (! empty($arrayfields['origin']['checked'])) { @@ -824,9 +914,10 @@ if ($resql) print ''; } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook @@ -862,10 +953,11 @@ if ($resql) if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); - + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -981,6 +1073,11 @@ if ($resql) { // Label of movement print ''; + } + if (! empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + print ''; } if (! empty($arrayfields['origin']['checked'])) { @@ -1059,6 +1156,54 @@ else dol_print_error($db); } +/* + * Documents generes + */ + +$modulepart='mouvement'; + +if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) +{ + print '
'; + print '
'; + print ''; // ancre + + // Documents + $objectref = dol_sanitizeFileName($object->ref); + // Add inventorycode & type_mouvement to filename of the pdf + if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; + if($search_type_mouvement) $objectref.="_".$search_type_mouvement; + $relativepath = $comref . '/' . $objectref . '.pdf'; + $filedir = $conf->stock->dir_output . '/mouvement/' . $objectref; + + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; + $genallowed=$usercanread; + $delallowed=$usercancreate; + + $genallowed=$user->rights->stock->mouvement->lire; + $delallowed=$user->rights->stock->mouvement->creer; + + $var=true; + + print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + $somethingshown=$formfile->numoffiles; + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + + print '
'; +} + llxFooter(); $db->close(); From ea4c48047a80e19ddc458cdf24795cd09c21b27c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:30:27 +0200 Subject: [PATCH 097/183] All new hooks must be addreplace hooks --- htdocs/core/lib/security.lib.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 15047b2f2d7..b599fac3cfb 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -111,21 +111,23 @@ function dol_hash($chain,$type=0) */ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) { - global $db, $conf; + global $db, $conf; + global $hookmanager; //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; - // If we use canvas, we try to use function that overlod restrictarea if provided with canvas - if (is_object($objcanvas)) - { - if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); - } - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + // Get more permissions checks from hooks + $hookmanager->initHooks(array('permissions')); + $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); + $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); + if (isset($hookmanager->resArray['result']) && empty($hookmanager->resArray['result']) return false; + if ($reshook > 0) return true; + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); @@ -206,7 +208,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check write permission from module $createok=1; $nbko=0; - if (GETPOST("action") == 'create') + if (GETPOST("action","apha") == 'create') { foreach ($featuresarray as $feature) { @@ -261,7 +263,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check create user permission $createuserok=1; - if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes') + if (GETPOST("action","alpha") == 'confirm_create_user' && GETPOST("confirm","alpha") == 'yes') { if (! $user->rights->user->user->creer) $createuserok=0; @@ -271,7 +273,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check delete permission from module $deleteok=1; $nbko=0; - if ((GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST("action") == 'delete') + if ((GETPOST("action","alpha") == 'confirm_delete' && GETPOST("confirm","alpha") == 'yes') || GETPOST("action","alpha") == 'delete') { foreach ($featuresarray as $feature) { @@ -335,13 +337,6 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu accessforbidden(); } - // get more permissions checks from hooks - global $hookmanager; - $hookmanager->initHooks(array('permissions')); - $parameters=array('features'=>$features,'objectid'=>preg_replace("/'/", '', $objectid),'idtype'=>$dbt_select); - $reshook=$hookmanager->executeHooks('restricted',$parameters); - if ($reshook < 0) accessforbidden(); - return 1; } From 0891766a3e631068e17363be7d8a5b532dc5b226 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:31:27 +0200 Subject: [PATCH 098/183] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b599fac3cfb..86226587416 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -333,8 +333,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) - accessforbidden(); + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) + return $ok ? 1 : accessforbidden(); } return 1; From 7be804dcf552f62639bd29ff494e08ad70c8381c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:32:08 +0200 Subject: [PATCH 099/183] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 86226587416..14c9be76abe 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -333,8 +333,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) - return $ok ? 1 : accessforbidden(); + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + return $ok ? 1 : accessforbidden(); } return 1; From bc9eaaab8407f2b640b04fb43d6a383111ce4ff8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:34:20 +0200 Subject: [PATCH 100/183] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 14c9be76abe..ceebdd63681 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -125,8 +125,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu $hookmanager->initHooks(array('permissions')); $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); - if (isset($hookmanager->resArray['result']) && empty($hookmanager->resArray['result']) return false; - if ($reshook > 0) return true; + if (! empty($hookmanager->resArray['result']) return true; + if ($reshook > 0) return false; // Features/modules to check $featuresarray = array($features); From 9077f18dd683c43896096353bfd16575b34186c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:37:22 +0200 Subject: [PATCH 101/183] Update security.lib.php --- htdocs/core/lib/security.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5101772ac66..f89bba09a76 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -189,7 +189,6 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; // Get more permissions checks from hooks - $hookmanager->initHooks(array('permissions')); $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); if (! empty($hookmanager->resArray['result']) return true; From 56b80d81dd94f23dcf7c4267de44e819725b453a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:39:29 +0200 Subject: [PATCH 102/183] Declare hook as addreplace hook --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 5c1f1358784..cd33f1d8d02 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -182,6 +182,7 @@ class HookManager 'printTabsHead', 'printObjectLine', 'printObjectSubLine', + 'restrictedArea', 'sendMail', 'sendMailAfter', 'showLinkToObjectBlock', From 4efc9f95cd03be3234da33bba149796feb9d1b93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:48:18 +0200 Subject: [PATCH 103/183] FIX #8775 (try better fix) --- htdocs/compta/ajaxpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 01fe12e50f4..5e83b3032c1 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -61,7 +61,7 @@ foreach ($remains as $key => $value) } // Treatment -$result = $amountPayment != '' ? ($amountPayment - array_sum($amounts)) : ($amountPayment + array_sum($amounts)); // Remaining amountPayment +$result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment'); From 842c6168a25cbd90d3b8d616b8d5841662e3aab9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:50:35 +0200 Subject: [PATCH 104/183] FIX #8762 --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 05c5982dc00..e09b6cd2bb0 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -498,7 +498,7 @@ class FormFile $modellist=ModelePDFCards::liste_modeles($this->db); } } - elseif ($modulepart == 'agenda') + elseif ($modulepart == 'agenda' || $modulepart == 'actions') { if (is_array($genallowed)) $modellist=$genallowed; else From f476e3e304e30acb079c2ee426a2f84f0be09d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:56:49 +0200 Subject: [PATCH 105/183] Update translate.class.php --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ec3ed00a313..55b853f5c8e 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -576,7 +576,7 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } - dol_syslog(__METHOD__."missing translation ".$newstr." in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + dol_syslog(__METHOD__."missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); return $newstr; } From c094a6c43ed41c0af0027cd27399a9eaf683f065 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 12:29:58 +0200 Subject: [PATCH 106/183] Reorder permissions --- htdocs/core/lib/security.lib.php | 4 +- htdocs/core/modules/modFournisseur.class.php | 45 ++++++++------------ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index f89bba09a76..45a96f9a527 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -191,9 +191,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Get more permissions checks from hooks $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); - if (! empty($hookmanager->resArray['result']) return true; + if (! empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; - + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 69e749a4c92..cfac00e14c1 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -165,14 +165,6 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'approuver'; - /*$r++; - $this->rights[$r][0] = 1191; - $this->rights[$r][1] = 'Approuver une commande fournisseur (si supérieur hiérarchique)'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'approve_ifsupervisor_advance';*/ - $r++; $this->rights[$r][0] = 1186; $this->rights[$r][1] = 'Commander une commande fournisseur'; @@ -205,6 +197,24 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'supprimer'; + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + { + $r++; + $this->rights[$r][0] = 1190; + $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande'; + $this->rights[$r][5] = 'approve2'; + } + + $r++; + $this->rights[$r][0] = 1191; + $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande'; + $this->rights[$r][5] = 'export'; $r++; $this->rights[$r][0] = 1231; @@ -254,25 +264,6 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'facture'; $this->rights[$r][5] = 'export'; - $r++; - $this->rights[$r][0] = 1237; - $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'export'; - - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) - { - $r++; - $this->rights[$r][0] = 1190; - $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'approve2'; - } - // Menus //------- From 63b9384ef6ea3e0ad2af852ee301a1a2b21baa40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 12:34:23 +0200 Subject: [PATCH 107/183] No transmormation of data objectid before calling trigger --- htdocs/core/lib/security.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 45a96f9a527..502f962dede 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -186,15 +186,15 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; - // Get more permissions checks from hooks $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); if (! empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; - // Features/modules to check + if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); From 70a185a9e640af08895074e7fa0f8966e93f9310 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 13:11:52 +0200 Subject: [PATCH 108/183] Update main.inc.php --- htdocs/main.inc.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bd803febe5f..cd728711244 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1253,35 +1253,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } } - //Overload css files to the current module - // Check if the /module/style folder exists and add the contains css files to head - $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); - if(is_array($cur_modulepart) && count($cur_modulepart)>0) - { - foreach($conf->modules as $module) - { - if(in_array($module, $cur_modulepart)) - { - if (file_exists(getcwd().DIRECTORY_SEPARATOR."style")) - { - //browse the style dir and add the contains css files - if ($handle = opendir(getcwd().DIRECTORY_SEPARATOR."style")) - { - while (false !== ($entry = readdir($handle))) - { - list($filename, $extension) = explode(".", $entry); - if ($entry !== '.' && $entry !== '..' && $extension == 'css') - { - print ''."\n"; - } - } - closedir($handle); - } - } - } - } - } - // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From a6966fe295b5849e8682b774158d71c32afce57d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 13:12:24 +0200 Subject: [PATCH 109/183] Update main.inc.php --- htdocs/main.inc.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index cd728711244..eaea0dc420c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1234,25 +1234,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; - //Overload css files to the current theme - // Check if the /theme/nameoftheme/style folder exists and add the contains css files to head - if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) - { - //browse the style dir and add the contains css files - if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) - { - while (false !== ($entry = readdir($handle))) - { - list($filename, $extension) = explode(".", $entry); - if ($entry !== '.' && $entry !== '..' && $extension == 'css') - { - print ''."\n"; - } - } - closedir($handle); - } - } - // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From 0c35bc52842eb3e88ebdc8e55cdc90591c3708d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 14:15:52 +0200 Subject: [PATCH 110/183] Standardize code --- htdocs/core/modules/dons/modules_don.php | 111 ----------------------- htdocs/don/card.php | 13 ++- htdocs/don/class/don.class.php | 108 ++++++++++++++++++++++ htdocs/expedition/card.php | 41 +-------- htdocs/livraison/card.php | 15 ++- 5 files changed, 135 insertions(+), 153 deletions(-) diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 14045f20d11..4949cce94e1 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -139,114 +139,3 @@ abstract class ModeleNumRefDons } } - -/** - * Cree un don sur disque en fonction du modele de DON_ADDON_PDF - * - * @param DoliDB $db Databse handler - * @param int $id Id donation - * @param string $message Message - * @param string $modele Force le modele a utiliser ('' par defaut) - * @param Translate $outputlangs Object langs - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @return int 0 if KO, 1 if OK - */ -function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) -{ - global $conf, $langs; - $langs->load("bills"); - - $eror=0; - - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); - - $srctemplatepath=''; - - // Set template to use - if (! dol_strlen($modele)) - { - if (! empty($conf->global->DON_ADDON_MODEL)) - { - $modele = $conf->global->DON_ADDON_MODEL; - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_DON_ADDON_MODEL_NotDefined"); - return 0; - } - } - - // If selected modele is a filename template (then $modele="modelname:filename") - $tmp=explode(':',$modele,2); - if (! empty($tmp[1])) - { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } - - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('html','doc','pdf') as $prefix) - { - $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; - - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir."core/modules/dons/".$file,0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } - - // Charge le modele - if ($filefound) - { - require_once $file; - - $object=new Don($db); - $object->fetch($id); - - $classname = $modele; - $obj = new $classname($db); - - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) - { - $outputlangs->charset_output=$sav_charset_output; - - // we delete preview files - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($object); - return 1; - } - else - { - $outputlangs->charset_output=$sav_charset_output; - dol_syslog("Erreur dans don_create"); - dol_print_error($db,$obj->error); - return 0; - } - } - else - { - print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); - return 0; - } -} - diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 375b49bd4d1..46f223d3857 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -242,8 +242,15 @@ else if ($action == 'classin' && $user->rights->don->creer) $object->fetch($id); $object->setProject($projectid); } + +// Actions to build doc +$upload_dir = $conf->don->dir_output; +$permissioncreate = $user->rights->don->creer; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + // Remove file in doc form -if ($action == 'remove_file') +/*if ($action == 'remove_file') { $object = new Don($db, 0, $_GET['id']); if ($object->fetch($id)) @@ -261,11 +268,12 @@ if ($action == 'remove_file') $action=''; } } +*/ /* * Build doc */ - +/* if ($action == 'builddoc') { $object = new Don($db); @@ -291,6 +299,7 @@ if ($action == 'builddoc') exit; } } +*/ /* diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 78e3a57f436..90cf8bad1b4 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -931,4 +931,112 @@ class Don extends CommonObject } } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$langs; + + $langs->load("bills"); + + if (! dol_strlen($modele)) { + + $modele = 'html_cerfafr'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->DON_ADDON_MODEL)) { + $modele = $conf->global->DON_ADDON_MODEL; + } + } + + $modelpath = "core/modules/dons/"; + + // TODO Restore use of commonGenerateDocument instead of dedicated code here + //return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); + + $srctemplatepath=''; + + // If selected modele is a filename template (then $modele="modelname:filename") + $tmp=explode(':',$modele,2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('html','doc','pdf') as $prefix) + { + $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; + + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir."core/modules/dons/".$file,0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } + + // Charge le modele + if ($filefound) + { + require_once $file; + + $object=$this; + + $classname = $modele; + $obj = new $classname($db); + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) + { + $outputlangs->charset_output=$sav_charset_output; + + // we delete preview files + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($object); + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_syslog("Erreur dans don_create"); + dol_print_error($db,$obj->error); + return 0; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); + return 0; + } + } + } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 078d77c47c9..ddf819ad692 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -123,6 +123,11 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + // Actions to build doc + $upload_dir = $conf->expedition->dir_output.'/sending'; + $permissioncreate = $user->rights->expedition->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Reopen if ($action == 'reopen' && $user->rights->expedition->creer) { @@ -533,42 +538,6 @@ if (empty($reshook)) $action=""; } - // Build document - else if ($action == 'builddoc') // En get ou en post - { - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } - - // Delete file in doc form - elseif ($action == 'remove_file') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $upload_dir = $conf->expedition->dir_output . "/sending"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - elseif ($action == 'classifybilled') { $object->fetch($id); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b6b25424e65..caee19a2c34 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -45,11 +45,8 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } +$langs->loadLangs(array("sendings","bills",'deliveries','orders')); -$langs->load("sendings"); -$langs->load("bills"); -$langs->load('deliveries'); -$langs->load('orders'); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $action=GETPOST('action', 'alpha'); @@ -77,9 +74,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('deliverycard','globalcard')); + /* * Actions */ + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -245,9 +244,16 @@ if ($action == 'update_extras_line') } +// Actions to build doc +$upload_dir = $conf->expedition->dir_output.'/receipt'; +$permissioncreate = $user->rights->expedition->creer; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + /* * Build document */ +/* if ($action == 'builddoc') // En get ou en post { // Save last template used to generate document @@ -283,6 +289,7 @@ elseif ($action == 'remove_file') if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } +*/ /* From 7f704231fecbeccc520606cd014ad4e88202c073 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 14:20:05 +0200 Subject: [PATCH 111/183] Fix migration script --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 2e5395cb714..a57e02455cc 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -470,6 +470,6 @@ ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code ( UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; -- Warehouse -ALTER TABLE `llx_entrepot` ADD `model_pdf` VARCHAR(255) AFTER `fk_user_author`; -ALTER TABLE `llx_stock_mouvement` ADD `model_pdf` VARCHAR(255) AFTER `origintype`; +ALTER TABLE llx_entrepot ADD COLUMN model_pdf VARCHAR(255) AFTER fk_user_author; +ALTER TABLE llx_stock_mouvement ADD COLUMN model_pdf VARCHAR(255) AFTER origintype; From ce40a51bdb15ce44f78c91504ef73f017eca2196 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Thu, 10 May 2018 16:08:45 +0200 Subject: [PATCH 112/183] inversion of dateo and datee --- htdocs/fichinter/class/fichinter.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 25f2e691265..f7cb22f5462 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -354,8 +354,8 @@ class Fichinter extends CommonObject $this->statut = $obj->fk_statut; $this->duration = $obj->duree; $this->datec = $this->db->jdate($obj->datec); - $this->datee = $this->db->jdate($obj->dateo); - $this->dateo = $this->db->jdate($obj->datee); + $this->dateo = $this->db->jdate($obj->dateo); + $this->datee = $this->db->jdate($obj->datee); $this->datet = $this->db->jdate($obj->datet); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); From 9315d9c423ee9b4ffbbee194ffbf399f5886f132 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 18:56:21 +0200 Subject: [PATCH 113/183] NEW Introduce permission "approve" for "leave request" like for "expense report" --- htdocs/core/modules/modHoliday.class.php | 19 +++++++---- htdocs/expensereport/card.php | 2 ++ htdocs/holiday/card.php | 28 +++++++++++++--- htdocs/holiday/class/holiday.class.php | 42 ++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 3fd056b525e..e60be690ce4 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -108,42 +108,49 @@ class modHoliday extends DolibarrModules $r=0; $this->rights[$r][0] = 20001; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read your own holidays'; // Permission label + $this->rights[$r][1] = 'Read your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20002; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label + $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20003; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete holidays'; // Permission label + $this->rights[$r][1] = 'Delete leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; + $this->rights[$r][0] = 20007; + $this->rights[$r][1] = 'Approve leave requests'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'approve'; + $r++; + $this->rights[$r][0] = 20004; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read holidays for everybody'; // Permission label + $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20005; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify holidays for everybody'; // Permission label + $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20006; // Permission id (must not be already used) - $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label + $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a2d67d627c0..d17ae2eb095 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1346,6 +1346,7 @@ if ($action == 'create') print ''; print '
'; + // User for expense report print ''; print ''; print ''; print ''; + // Approver print ''; print ''; print '"; print ''."\n"; + print ''."\n"; - print ''."\n"; + print ''."\n"; - print ''."\n"; + print ''."\n"; // Country diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4c236324373..7d23822486f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -451,10 +451,11 @@ abstract class CommonObject * @param int $withregion 1=Add region into address string * @return string Full address string */ - function getFullAddress($withcountry=0,$sep="\n",$withregion=0) + function getFullAddress($withcountry=0, $sep="\n", $withregion=0) { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { + $langs->load("dict"); require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; $tmparray=getCountry($this->country_id,'all'); $this->country_code=$tmparray['code']; diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index fe96d7c0f97..23048bc921f 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -91,8 +91,8 @@ FailedToCreateAdminLogin=Failed to create Dolibarr administrator account. WarningRemoveInstallDir=Warning, for security reasons, once the install or upgrade is complete, to avoid using install tools again, you should add a file called install.lock into Dolibarr document directory, in order to avoid malicious use of it. FunctionNotAvailableInThisPHP=Not available on this PHP ChoosedMigrateScript=Choose migration script -DataMigration=Data migration -DatabaseMigration=Structure database migration +DataMigration=Database migration (data) +DatabaseMigration=Database migration (structure + some data) ProcessMigrateScript=Script processing ChooseYourSetupMode=Choose your setup mode and click "Start"... FreshInstall=Fresh install diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang index 48d92644763..c83288b2a3d 100644 --- a/htdocs/langs/fr_FR/install.lang +++ b/htdocs/langs/fr_FR/install.lang @@ -92,7 +92,7 @@ WarningRemoveInstallDir=Attention, pour des raisons de sécurité, afin de bloqu FunctionNotAvailableInThisPHP=Non disponible sur ce PHP ChoosedMigrateScript=Choix du script de migration DataMigration=Migration des données -DatabaseMigration=Migration du format de la base de données +DatabaseMigration=Migration de la base de données (structure + données) ProcessMigrateScript=Exécution du script ChooseYourSetupMode=Choisissez votre mode d'installation et cliquez sur "Démarrer"… FreshInstall=Première installation From 1b20ec05d10bd717b6889594d2534d71a466d0ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 19:37:47 +0200 Subject: [PATCH 174/183] Save translation --- htdocs/core/class/commonobject.class.php | 3 +-- htdocs/core/lib/functions.lib.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index adbb77ae6b9..ee811e3b81a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -455,7 +455,6 @@ abstract class CommonObject { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { - $langs->load("dict"); require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; $tmparray=getCountry($this->country_id,'all'); $this->country_code=$tmparray['code']; @@ -2705,7 +2704,7 @@ abstract class CommonObject $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; $sql .= ' WHERE rowid = '.$this->id; - + dol_syslog(get_class($this)."::update_price", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 123334eee25..153ebab4c89 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1654,9 +1654,9 @@ function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', } else if (in_array($object->country_code,array('IT'))) // IT: tile firstname name\n address lines \n zip (Code Departement) \n country { - $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); - $ret .= ($object->departement_id?(' ('.($object->departement_id).')'):''); + $ret .= ($ret ? $sep : '' ).$object->zip; + $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); + $ret .= ($object->departement_id?(' ('.($object->departement_id).')'):''); } else // Other: title firstname name \n address lines \n zip town \n country { @@ -1668,7 +1668,11 @@ function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', } } if (! is_object($outputlangs)) $outputlangs=$langs; - if ($withcountry) $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); + if ($withcountry) + { + $langs->load("dict"); + $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); + } return $ret; } From e5561ecdfb92576509bc1892dc7fe0d0ca919ba4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 22:14:15 +0200 Subject: [PATCH 175/183] Remove useless files --- .../template/dev/codesniffer/DolibarrPSR2.xml | 12 - .../template/dev/git-hooks/README | 15 - .../template/dev/git-hooks/post-commit | 2 - .../template/dev/git-hooks/pre-commit | 2 - .../template/dev/git-hooks/pre-push | 2 - .../modulebuilder/template/dev/img/README.md | 53 --- .../template/dev/img/gfdl-129x44.png | Bin 4709 -> 0 bytes .../template/dev/img/gfdl-66x23.png | Bin 2453 -> 0 bytes .../template/dev/img/gfdl-logo.svg | 110 ----- .../template/dev/img/gpl-v3-logo.svg | 389 ------------------ .../template/dev/img/gplv3-127x51.png | Bin 3471 -> 0 bytes .../template/dev/img/gplv3-88x31.png | Bin 2666 -> 0 bytes .../template/dev/img/mymodule.svg | 70 ---- 13 files changed, 655 deletions(-) delete mode 100644 htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml delete mode 100644 htdocs/modulebuilder/template/dev/git-hooks/README delete mode 100755 htdocs/modulebuilder/template/dev/git-hooks/post-commit delete mode 100755 htdocs/modulebuilder/template/dev/git-hooks/pre-commit delete mode 100755 htdocs/modulebuilder/template/dev/git-hooks/pre-push delete mode 100644 htdocs/modulebuilder/template/dev/img/README.md delete mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-129x44.png delete mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-66x23.png delete mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-logo.svg delete mode 100644 htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg delete mode 100644 htdocs/modulebuilder/template/dev/img/gplv3-127x51.png delete mode 100644 htdocs/modulebuilder/template/dev/img/gplv3-88x31.png delete mode 100644 htdocs/modulebuilder/template/dev/img/mymodule.svg diff --git a/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml b/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml deleted file mode 100644 index 48d3f5d8d1d..00000000000 --- a/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - The PSR2 standard with Dolibarr quirks. - - - - - - - - - \ No newline at end of file diff --git a/htdocs/modulebuilder/template/dev/git-hooks/README b/htdocs/modulebuilder/template/dev/git-hooks/README deleted file mode 100644 index a5d024c1bf5..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/README +++ /dev/null @@ -1,15 +0,0 @@ -# Git hooks - -Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided. -These are just wrappers calling composer scripts. -They ensure best practices are followed during module development. - -Install: -```sh -composer git_hooks_install -``` - -Remove: -```sh -composer git_hooks_remove -``` diff --git a/htdocs/modulebuilder/template/dev/git-hooks/post-commit b/htdocs/modulebuilder/template/dev/git-hooks/post-commit deleted file mode 100755 index d44ff23047c..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/post-commit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_post_commit diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-commit b/htdocs/modulebuilder/template/dev/git-hooks/pre-commit deleted file mode 100755 index d8bd735325c..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/pre-commit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_pre_commit diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-push b/htdocs/modulebuilder/template/dev/git-hooks/pre-push deleted file mode 100755 index 61848c24831..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/pre-push +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_pre_push diff --git a/htdocs/modulebuilder/template/dev/img/README.md b/htdocs/modulebuilder/template/dev/img/README.md deleted file mode 100644 index f44c37f30c6..00000000000 --- a/htdocs/modulebuilder/template/dev/img/README.md +++ /dev/null @@ -1,53 +0,0 @@ -Source images -============= - -Used to generate icons and publication assets. - -Icons ------ - -### Dolibarr - -These resides in the [/img](../../img) directory. - -#### Small - -Required. -Name must begin by ```object_```. - -- Sample: ![object_mymodule.png](../../img/object_mymodule.png) [object_mymodule.png](../../img/object_mymodule.png) -- Size: 14×14 pixels -- Type: PNG - -#### Large - -Optional. - -- Sample: ![mymodule.png](../../img/mymodule.png) [mymodule.png](../../img/mymodule.png) -- Size: 32×32 pixels -- Type: PNG - -### Dolistore - -Designed to fit a 512×512 icon + publisher branding. - -- Size: 704×704 -- Type: PNG - -Export to 512×512 - -### Transifex - -- Size: 96×96 -- Type: PNG - -### Others - -To be on the safe side, you may also want to generate all popular sizes: -- 16×16 -- 32×32 -- 48×48 -- 64×64 -- 128×128 -- 256×256 -- 512×512 diff --git a/htdocs/modulebuilder/template/dev/img/gfdl-129x44.png b/htdocs/modulebuilder/template/dev/img/gfdl-129x44.png deleted file mode 100644 index f2bacfd179a99f051654eaa6ba30089dd8691d7a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4709 zcmV-r5}NIaP)00004b3#c}2nYxW zd%dU$Ce+szoV9OJ5UN#164pJ za0WO590CqYl2p=>Ff$P7r^@&6|A`4W3~T|`N|IF5`l0|F2QD6e^`*?6HSvE?zuzWy zyMy#Y+3fr|ot#{w$8|vvh>MLRF(HQFAT4@*Ao`#{g7ksTbDaj8&CYi}{6cX_1=ZDc z)YjEgS$PJ#-O--t24Fq#t|UnZ!Knn_0@G$(KZf-mukiof_TYiBsGJ!$KgNmd)2_I% zupp*S8%=UjB1uCNNE#A{R;xjhB#KKaFq<0@MLTx81H0YsJa;&-+Z{wk7>JLH0>Er; z;H!;4^RM+=*|RqjNs<^kIF5*jFm~)Z&{jb{0u~CuTR_UtA@QW`S$zQ?#cvabLt^BW z3&}d+RDe+<2eatz8QgTkIC63eIdnLOoLnP$`9;oSUJ;E=mUhe3^iorh^99<#UT*QJ z`!Y#+=ygtHpJvG5I6nBtpV+u*45;IFTL%GwW}e%XH%;1QP+nClxUFRvjyJoth{N~xTIhDEdo^gc(H37_?HGxG7Zy-4-fzq-nKHso|^h4QX9?2s+rw~!J zcdBeb5YXu~gaqpd3DFTB7sY_Y7_Ph`i7}&-*|a5<_dnRgp1m2Zv)Ke70H?<&tXcgy zbIzfKV6oW9$t~pA@sqCK>B2G$20f7xVMIiPGIVep)23dDPN(t6Z?13T+s&z{RLbU` z0<}tsAPCs)4n(^hi^WD$lNF1_iq$F-7#M&~r{R+1M4}?Y`1G?MQK^)u)k@SV6)Kei zheN_9ir8!-qG-ovvm=Tkf*{bpe*^;)`w|kO>(o8|`}6H6l?v2qB>`#`N~Hp;Rm5Vo zVzJl&xcSC$9hTEt31l(>hvTgIPfUm=IVq9kqy(pPI5eImB&kUdgd!lO zpo@NiBuT7UyO}4SSxsGCLx<_rY9*7e8O7Y$lel5}7*~8%RV|B_ywXwA#w#!Wc@Yn$ z%;w$)UUM^}oyA}XVqjtn6UJXg%92~WDk;D{_r2V1{S1bnPANfa4y3K&ll9y9=eqAH zGgXnBS43`J5nq12%aul})esV_MW@rC*9AI{dJS5w22r$ASJyyoU48Sh0drjgl~rf3 zTD?CDwOZ*?+7<*!k`M%87clnrTd!sHyN`D226FR?c;LamvOCpjT4XYTDc4@XsLKa) z`G`Tp#Pr5!G;u8JB%gn=qs0jUAV966vUH1Ec@BrfR~vt3@sd~Eyx{=@`Vt)#My~)h z0Rbv%>l&!2sNv|b0z}cy>USUI_FJz7V8_mbELi*!CR4R5|G2TknL7CjR4N5|c|~OB z6q21&NTIRJ?OzBG8mi}CYoBK9Rl_{)x4gWDox9Wd(-W&&d)CDEkKm=}?`8Dwk}w#8 zI(%-eEkR}J76Q~NY&Mbax2BQypJQZX=8<_M&+Q)06`4#RAwHVqqy)mkg86#m&y<;} z35gtyrM{Sk+5!NJqB(sYFt)QTgiV`Mx$Ev1T`xE)cD@7dov5olb*Jt05#r$Dl#63>h3pLwys^zOaV(KKKTQL&6Xfjh3^@Ipr=D5Ot{+!= z%@-W3bqj}tbWUDZ>C-!uYbJ(r&BT#i&fCyv;k)mD;cstz$`9Mpuv$gbns6c#XAu-W z8~{O(wImnZl%S-vk|v9l0JX}efECZJaWhqqKYB-p3eZAKbU1x_htR)YgwHg=!JTu| zf`YVYwHl8mZD=PQy%y%onn-lEn`k+A9HN8F%l~PG@Nd?9t6Go$nLZb}wX#c9TyW?0 zTsmxEm-2KsDwTo}xRPQy#j-^*S1yof>-L}cPj>|!Gh zu@Sr2(CXKSU2H^h*ifoNPzHpe3J66RU~nCk>JYaV>E3QbA**g@pL%^De7}acx=zk|a@RG?AF#KN;;Y`<4m3 zzh)Du`!Ycg2k}oBQo<{`P7La=DDs+zmMFP2DO>ke#&zo=V`u66EF@-980!xyyAb5%8Br+Y z9VhGpp`m&Y(|_{Rg;j!~L*iMqa0WI@4Q2V8x>=g1PXNtIknh71WVIUm28fI>`29tA zBe-?W zHT>h9KN1;XaJzQHjH?LL1az(D&4h;PJ<2;@T8|70g1{4x&G&2h=Yqiy#ERv2;jr5% z&i>S|WqT+A&Hey5&Au;|J$##6UwQhW?6y;td@zOd-0A~kKd*Arvqy%oib+TLB z%6B*TuVP-1EcHRj1 zumpW$dUx0Xv|{-JH#7e2mc6W6{k7jJ*LId{eVeeqS@+2gtbT8!E4=LCTm9A@ZZcJ4 zGFAJWvepr1a|1Weev*oc8X^;Cq7S>oFZBXI@Ekixfc8HHEkyJQ<>{yHa)l*HV%cLW z`OB;8{8G1?n!0ww9nsN3jTWk^YPoIx3Krl0sw>ZfDYHBD1)3T=S3W>SrgLysuj~3! zPlrQd{(=`co^_It$kBxNpWJb#F5oeWNV5{e`)D4v<$?QVk`N!w;`?8vvbl%xxfj=R zFg=^=rd+|evBQarjiji!oYZ}p?A@E$slk}66Q?j1xqHF;e?3lJT|=k;O<7r|+`>Qa zIYdaX4xL`Z$&)3V$Sx#1=QLSar>Jjm4$|oLfvi}*fW>#;&|&$Xt5tN( zkZx?Uay;uKM~)Vdo9A3(crKRU@u&XI58KiR3?4|##q+wHzazZOCvbKY_3wN?_0-8% zus`)Z7A}5?ox9Qj*!e*Gf&`KNb$wkYg&2TLD)+rtU_ar>|QxcyhJc?^aiX3reYW6S1s zxah{=ka&36Tds+FS%U9UF=MV?evpJNJL;9f{@(YSFn;VFU4ksqMH~sqdVanuDOuv4N*A5u9 zO39=NBb+O2RL)g4a=FYozh1N>+MILk<#OMXC9F0ZGMS7A?wg51DMzJLy2`NHM8xK` z2RfaG$jC4TCdM#s?C?$xg0;y1!~M6o)<*zXtu|NrR;%c$M}S&|IzUB$TIqFStuJ=& zO6Q?vZ=z84A~rb%xl-G4rgNaRB@lpNKsrF`&Q%P%WI(qF?ZJt+Dd#QZ=lSh4Zwkyu11U**Z!Xw&5P^)DBDsa~Oac(|+vsCW68*B``Pvg{tFKP3<8$Y*-phn5(leR~@6iCL6oxK6TBd1il82 zdhjp0RxO1>qlrNm$MXEMi{)qMWt4gglYy^Q(urnp_V+a2uPm&tcq(?~y*O-5#3mpjZ_ z2o2Q}+dqQX{*hchaxjx7T*jb_W3gIA=FWSDAGW0doD^_wdlqtDch(|WraUuzr+ zjV6vAFQB%r0ZWsWCX2OsnZ9$mev`$DDB6jN3~PSr&KKXdld7n=oDV)9GUg1KF z()HkpAP7p}W?%_0*2{I`Vk5cuqW%O2YtQaYpwpn!2cpyVLKN-P)-|~8QBYUcK$)qU zBS-UHUHWbC+`_I$3I6v8f-nTQ8@LikqLqd46YXzi*`oyiUkJ|Oy#Y9Ta);rZ1+H)Y n1+_VfIJdB^ZFB6>wzmHTwMhFML%JGy00000NkvXXu0mjfK;ap? diff --git a/htdocs/modulebuilder/template/dev/img/gfdl-66x23.png b/htdocs/modulebuilder/template/dev/img/gfdl-66x23.png deleted file mode 100644 index b43479bf3c817b3f780eb453ef3c4e770e1ddc35..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2453 zcmV;G32OFElDZw|yVYEgfW}Cy|k! zgx#J@dYX;&G#ew5FXBW=C5OK*=2TfN#mCEavsn&k0X^XE@ra^mcvn%BC6d8lC^yN* zgv%!6U+9|78#_Pv8yh$6;F+iA^Rt^S=eg(K;ne9GKHv8bT3R{~4F)91KtjBg?~c9+ zKp>zA^B;UpI`(a;w0h+{e!c3A*(XaX3nahaf8umSeE}d`*s{(aZ~lHS27`z_BN>w{ z)8p|{e7u6l2osYhk4831$g&YhGH}an%V}%tqN%AJS(dos@=M5aq|oK^N}8tUONtUG zDJ`w`0p`JiH8*$g$)CTX_;@+BbuEm(IE%|BY65MYMQ97X`-&a1yv0I5Fc+1&5g9wL>%^HzWsL<5pfe~ zt=*3Vlr=Q8nlw#E6wj`X-5(#~-uu^b)spr6vwa1c22VMN#3je)$7vnod)5J63BHW|K@^ zeG8v`euTB_-$N4<7?J-V-tJmJ2oj+N0%C1lGwEqI06bnF%O2Ydz`Cawgh=Rx$z){A z=xkE^BxjB=4VvWAC4~S)3?a|UP3NTz4{`0(MSQsX3r?0)F)}YBXk(V?7{<02KEJ|* z$@8dhXd}uJMRasDu`w26V=cJdUTSI@=;-Jo(h`fwl8GgC9%f5w(AHg#07$y7Hye$T zx1yrn+)KoPgU6_L6VRZl|O&rC@ybMm3RPoi} z??Xg{3$saP{kos?z@pbkaxNyIdT=Xly1IH04JP7p5=fM-gBuG12m&I2*(_I=SJa1O zC8ae06If01i z3@mX@BCVN7Ly-UkDL6xfrs?I?HBBL5d3hZGHe1|zC-lLt131SN;>f!_L})m;C?N&_ zzoMLX%wD|w!a_Q0KSB%m!Z#8`fFKc~ASA}cMTcaGiLn4QHn#V(2?R8HJU%o{M^yv3 zd%Wm+{|)D+8z*!0@ar5q@}DsG$gI0++eBqnhhIr+2jc>Vo!OeUGANHa;ccxK;ueb@=r z)wclPblStV84N2|%)!(4HGWTXcm};h2!asl_4?zoGE+jb3FDm@3?knbms3(&9r{1t z>EM%()-&_w;GVu{;q62YGtuW1O%E%V`i53coUCNb=xioU9QA|xHMK(*X|+bN>WMjY zRPP8YwjhWILU3th3If>e$su7@W(q}x)6jLD^)J3Nz}RG#0Wcb+(0`hyo%tQ~Y&I;` zJ@+<#zsgf9<_s0QT;9;oLqwOL?Amp*6K5xHhRw~=x z`IIMD{uV`10Z`QdE|+_NJC~~mfUd5AGJv+Wu23NW?jA2k|9O(4dsgw*w!LiLxP%+0 zO%Ca+Y9Qpx?e?Oo0ovPL?E2^+lEE-!SqBatW6iVgW6PUQIM=7%86g4Lj?853T!rMM zc)r}fg~dxY^759QY<+bXqef+N{6rk*vS0i+-r9q^#|yxe>lXHt&Aa#J zL5nJ{sORo`o*^-J!LVEAKq5d8MP9z^jvMCxX6vIv(yS;d#m6gXZ+DTFX2W4mMv~5| zd%QkGK}41%R5gIluV9Ia=;y=T<3%<~NRk0X37`f7!_F74&yPVAF&cwD{bw#}vTO`p z-WEN)0k7B3tDBe6?e;Kv$}iBPred{C42uMS?zZDp{%b2zgvmTAD=TH_UL!aQhB{#a zM3_zeboylzUaGDCCSi__;aD_I)!uA;PTl>aZDK2Z(k_hHoDtS z1Y_s|IeoXz9}~ - - - - - - - - - image/svg+xml - - - - - - - - - GFDL - - - - - - - diff --git a/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg b/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg deleted file mode 100644 index 6754c994bda..00000000000 --- a/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/htdocs/modulebuilder/template/dev/img/gplv3-127x51.png b/htdocs/modulebuilder/template/dev/img/gplv3-127x51.png deleted file mode 100644 index 3e9136e626683ac152b73bc8fffcb15d1806091a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3471 zcmV;A4RG>_P)00006VoOIv00000008+zyMF)x4ID{C zK~#9!?Okh_R#g=~B^4E=rR9Z+luC`X!sM1^DUntL7W9auAxV*!N`Y>UQ6*7FVLoW0N9 z``vrp*TJi)sqvcV#HTr)cj_~qccsv;g^Gk$2^|os5!x^J|1G}{&hosE`)!&Q?gXZ# zp7$;R^eUmr3TV(Sp+!Q4Lif-0ywL<7&r}HYO9Z|&{)+0nG13N{kP~IRb4cp%J@WT6 z@;gxIoDd8@EA$*TfozD2oWYj{ziH&)-y^i`I3C{~j;~sQ{)W)V*`9ZvD~=_ecZRgx zE$yZz0e?zk245DVqx`;doQ-QA+4oYRt-Mw(G(te^n1y}-5%6ph@V7T&;QuEQ@E!8| z;&CvZ!@`nF6`XZb&BVA1wG#vs2Ff;I%?bc!b7#hi1#YlDZ)Nh!e&l|gj? zS8ye1_jzgeQ|V)pnc(sy{b+jH^S&s3-eiE=rk|02Ulz6a(#Hkdk0JNWlTR2;JeerwD;HGprq{=ka>QJX5QbO?0kBTG>bg_=zZCha&4kqdn%6b zV$<(GRiC{LSc6>ploNZt0e=qryxm;CHv))K_1usggAPwyzR-nK=7OGCHq-My9EL}+ z=eZ%5|-hkA`anc7cXw&azb-%T_x86l7mPwrK zw<++vcfx+_xsw2kV#zA4fk=0Vyk*C+gS2u`z@e`OZH@0Is|8;3;teZb-QN_qYVjJ+p$&pdF6Ak46yKKFuuCdw?2llM=k7YWjL3&guc4a^FAcMa~<1&y&p>G zjeOCLSzA1^HjnGgXgOgL@VBZ3|E^i^nJIujB19{VqrqmJ1-w4ZjIn!MU$B1z=DjiD zJa)is3XPue@?3fZV{Lm0@t!5mT@B@z8>UAh@L_xF7sDNBoI5*H2&i0V-uakgyKk9x zvv@DhY^J*%^pO?;bDxl49$VoamecqiBva%t_*4?*{E2YvK#y3G6#Q$o$zs^^`6&fd zK4adw!Li+`W+U$6_0A#gUT3z?b^{#&`LCR^PeaCQcXbYE6#Nw#y1XC7K}`fcOeQtS zaSl;FI5QrPBE$tWtIW{3v(Ba_`C7IHl7Ljk^#>UpW95X=`dZsuHeU_{LWgRDJK4oM z;1%4K^yHVRLELQa6$U9H4lYJ5gX_p=04Iz2H3z!DY{Wa*-%2yawvJ}#X+erpO!CSq zKg^oLV9+LO1}7!B)Nue{Z8?Ka8~%_w`4>fOjHA&$3zU^nMh53)6{R}D?t7|n7MhKA zlglF4(Piq+@gE^=uqj&QIL~3!BG3Ck3bFeh#IKt(_{wyuH5asV2Pf3kJb^q6a}@{3 zXUN(69SIS!9p-)4n~gTk5&W}5)}VI~8}_|wj8E)JJDm)E1|x!6P;(zku~`b2xLp5& z1Ix$r6+sqFDEKg?)SwoaMd|D~neAp0&6KaYj(leDWp6eM7vM$Q;Hb22T}H$NbNn2JVTtT~ZL)w>hsfBt$xJoie@Wdhi@28wm22lt z0_E`-|AkqH*>wU?d`H^s9$ruA9`bt)6|^dcNa3XsZh3e-w?HWkJN1F!^MqC?5W5Gk z5|>HknRd6Rdxa7AGFiMCnM4Lj{UX5cuQdCUbHwiFGOevD!F&hBu=`O#c@44PL%B2T z^bDh9l{=n%E7ObA;QKl%SFS8GKf}o2F`UheYZ|rX3)Qs;8#v)~a16V@hH;KDaXLZJ zg!L)hm|+U{A?rNRE>oL+B?JCXmJ8A)lgJ=9&Ql>Wzq92G)J+t4lG5}uhIMA|y5+VQIPA#9|tIpODqSLvo*m9sXA!a11WLE3wVM1||CapnU zKn$yI$9b;{iru@Od>vE1CC<4MLRO|XZoI4 z-}QNr?{ThOa^&qW6~j!|SnyH1ZCK*P4$hq*Ioj8-&_AmC1ra%dnaKOUW#Zfk^GA?# ztV1D%S>WbLl(G~o0C3=z4vrjT0>2I=G-)fZ+ld4x*m`ORr$Y+_{bqnc&pC z4e0>q4>Pwq%q!*>KBPo2eFwv7_+2CVgN%Yn_uHN^2*4O(GMGQ{^;j=X|j!2l?e z&^ODsJF>duT%S9j4N9?)Mve#^HVi#&6A)yg;xk@O<(cqh^By+9a5!kdR{0qcI6*q$ z^m0x?dQE8TJ0L|GT&WL3$5WUtJ)H+94;F;3!pVfB?=REr#P}w zA&>1^Qsfk~9`9#VdhTY}braLXevgkv(Skr0Ob;b4hEa4Clr(F0Nt7=jN#$#3f=$VW6Xh*@(j{vbuYq@sws=T%rnA=_;?S6r{F<3oQhLA!%km*`)>J%^kix9qP z1v?sL+DOad^~K~2`>1tKM}nkZ$U)8a6mp4f90L+Sw&K)-BY_L>M8X6-%l9Eb#xgmh zfShYm1eeYlLfaU zxB)l=KT2>qS>!5In6Rd-HDy~lIT2*`G^8_;rEc(b6MWr+#SwUBGB?6dxHkC}j!oK! zz;_~0a|1Y9RDK@5H`oxM!$qsaQO-_#5coP@eg#v8tgCUkF;j+`WQQ$u;}(Y~d@I>z zm|s`tXXEmt2!55zW_+o`FJ~hATf&SMv@J))j?z)~bG$>SSQW84cBD4tFh}SeaZ$Or z$XVJ%U8RtR4RaZuG(SHp@KXq>Hl~j=mDb0?Q!g6A4GznpC`nKz74W(9nt-o+`Y+AZ zg2R%5;;R(wxi&kx-oTIfSkc?<)ce0EaO{-UB14CvB{Ykt93NVoVS`-t4nAdS6ZqzX z#&eG7Eg4tK!1@8;LVuxWu7>rE!|lhZ8WQ{^O`wNvfEp^g`C>Yr>7udIDw?f6%1}*{ zv!DGaRfB`ivgltnQC*sI#AmV5SPbx2JmeRTAXWii1-+Gf)U$AgjY1|+SS|f=0e;he xS`h1WfrqgdO~;o)s%+--KQtI%YYC5M`ag&6T?f%9P7444002ovPDHLkV1mp+x~c#G diff --git a/htdocs/modulebuilder/template/dev/img/gplv3-88x31.png b/htdocs/modulebuilder/template/dev/img/gplv3-88x31.png deleted file mode 100644 index ba78d4c4941dabf2fcac5409a92ac4c57920c69f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2666 zcmV-w3YGPVP)Px#32;bRa{vGVivR!tivi)#(!2lw00(qQO+^RT0uvMpF24YJ`L;(K) z{{a7>y{D4^014_zL_t(&-tC%skW|$b#(x5`77PlZ01Xf|tXfvU1+9P)Nl;9MMIeIW zf~A;|yxWx-F&@d<9Z!mSGK`{-NXD*+V< z1U?qnFHjo71r>243NtglEQV7Q5|M$wwPW#3mU1Xa75(4)}+D^1dj!r-wg;N!7wPTlz6cv~* zaG8PJ%ocdxi%_r(8VF2J2gJd((|x~-stE3f0*?zktgtfz_z{7D0<}|XS^^CmbayaJ zV6ea`S+E+%|4L05^x|!{8+(dT?jEM~Js`$27+y6h2%>GgYF0wJYE0l-O z)7o925Tv&W;2eAZgu;B5;j^dJ8-bz3oKpjkZt1g)zX^66mI| z)j_Xp5wNzxdh2k6HU6=}>lr5fjzC|47oe%aZiQ_MKeNs1Wz;5au`^ddqYxT8_`O0| z2+eKGVG3K)+k_Uu1%|7S@cDv!RA5U0Jp{%pe3tfppM%?rytQ5}8P;njwoMwi^#raG z_|!q~0P19O58V`YC~Ow^rGefh%fweYXuAOFEA&%1pirdH-T=NSi#0u9by^9`QxJv5 zHjl?NEpVEPINjb~s%aLOrIZQ$Er2cpYhwES(!o;>ZWd4fj>h!yt-vP^&Rzf~rSJ-% zg@aKFTLZW-2{m&$=#dIvD=Zf1XvcR*1&`sq0ThV$zmI09^NGMv1M6&ojS7EJsBiOF z8n;M=9{?nvrNFcK_*#Yg1^TDhK}Ke?#C57YX(PO#~hmZ&YIfXpm0?Of77b zcz4lUy){(?;9j;d=Zg=NarIQ8n^{2*frBCRE`gImI7i`?I3Q90+X5fTF_*Oh*9+WO z1x|lZpeTTXIJ}Zj$9dYg#Asf_jNm>ECo6nxzAm326$kDY0%zN14N};eq2A;GS}N34 z_?^POB%Ep+b3>f}wIrZv1mNKjYL#A=I=IZiomF5OUkN;%%t28n`n7hnwKmOUxi!^C z?!7sJ)RYjqCgH3A+6T}!^hf+gd!G=mbKa5;2^2Z#5Q*l| zfdhdl0@EDyF+dtC++#s#w6j4H&?112wh__NE(zy`FhF3r<@t|C0A7{B|L)KTzz$ld zr)$xAGn~&v$ExqQqQD+9qd48hXc$805H1yOr8Q%W^E8V!qcoEr7HA|sO)M9(j7va) zLPO)u<>K8*eH(mXo|E4b6{n4!WlMoas%ZhvALqY1(?UYejX$qum2H*6CFz(2o?R^x zDEv(hmVvj&jg=p^uDHvkZKlwQXnG#Q_KXL#Ubbsr9Nn7x7-IFOx}g0W@Fj z20>x8!ootY1Jtn~{dF~g`?~m)`Q!|iyHa6%kmfQnQM3*U9~p3ePDSc@Q2%*2Wf?S% zmJ%okp_W5IHRG)GOwilcdW(Gu*4g{T~>dyLTd*<7nqH5>P4bO#m15lF^bQk0@fXG4I;>Zi8G4~)h=aS0UnUjaR`^J~?z=+$ zHTWKdViR&!n`TiY-;I@$Nas4sHq*3$R%RqSBP!U};>Y>BK#9N@@vNzKHf)UY&9JQQ zCMxp?bTg|ev(NnmCWO%6!B~MAp&w|lz>EMc4xx`RjCHn%FPzVQekwkb8YeK{!Gi*~ zsNb|P0)6c!`IJklP`iK9vb6vc-7RoHJ0Nq5dRwk5m+UDA)gAo?O?LN0*eFN#QW*D#LIwjzkygL(4{)S zRcNGevoWb@0%ujrt~sxh79Qi@G*o92@TaP*zZ6=F7pc}Mlq8{3Nv<1-3c80vD-#)#iR!fAg3`3i=|n0Ep+VCB*yVN$x?2_YiZ5k$@3&Tcz#W!=Gm9%=?NxpL Y19h*OP%`Tk_W%F@07*qoM6N<$g8#_jNdN!< diff --git a/htdocs/modulebuilder/template/dev/img/mymodule.svg b/htdocs/modulebuilder/template/dev/img/mymodule.svg deleted file mode 100644 index f51ead1a94e..00000000000 --- a/htdocs/modulebuilder/template/dev/img/mymodule.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - M - - From 69141c9493e0c3c0804a359a70d1a5e96d843466 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 22:24:27 +0200 Subject: [PATCH 176/183] Fix PSR True->true and GETPOST file name for local checksum check --- htdocs/admin/system/filecheck.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 60c20dfafe7..e730b44821b 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -72,7 +72,7 @@ print '
'; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile')?GETPOST('xmlshortfile'):'/install/filelist-'.DOL_VERSION.'.xml'; +$xmlshortfile = GETPOST('xmlshortfile','alpha')?GETPOST('xmlshortfile','alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = GETPOST('xmlremote'); @@ -83,8 +83,8 @@ if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signa // Test if remote test is ok -$enableremotecheck = True; -if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; +$enableremotecheck = true; +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=false; $enableremotecheck = true; print ''; From afa57fd66d0bb813dba2c25b4cdc2467ee38e8b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 23:33:20 +0200 Subject: [PATCH 177/183] Fix syntax error --- htdocs/admin/system/filecheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index e730b44821b..fa9d46bf327 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -72,7 +72,7 @@ print '
'; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile','alpha')?GETPOST('xmlshortfile','alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)'.xml'; +$xmlshortfile = GETPOST('xmlshortfile','alpha')?GETPOST('xmlshortfile','alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = GETPOST('xmlremote'); From 7fce02e72ef4fb3aee3b51078c2dd6b7333321d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 23:43:26 +0200 Subject: [PATCH 178/183] Fix phpunit test name --- test/phpunit/{AccountingAccount.php => AccountingAccountTest.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/phpunit/{AccountingAccount.php => AccountingAccountTest.php} (100%) diff --git a/test/phpunit/AccountingAccount.php b/test/phpunit/AccountingAccountTest.php similarity index 100% rename from test/phpunit/AccountingAccount.php rename to test/phpunit/AccountingAccountTest.php From 2a579b707a83a5566020f4eeb5b572e8eedebaa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 May 2018 19:43:28 +0200 Subject: [PATCH 179/183] FIX javascript showempty error FIX Contact tab not visible when using canvas --- htdocs/core/class/html.formcompany.class.php | 3 +- htdocs/societe/contact.php | 67 ++++++++------------ 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index fbf77080de2..63babef655e 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -599,7 +599,8 @@ class FormCompany var method = obj.method; var url = obj.url; var htmlname = obj.htmlname; - console.log("Run runJsCodeForEvent-'.$htmlname.' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname); + var showempty = obj.showempty; + console.log("Run runJsCodeForEvent-'.$htmlname.' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname); $.getJSON(url, { action: method, diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index d57f61045c0..fb56c8b3dcb 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -102,7 +102,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { $action=''; if (! empty($backtopage)) @@ -139,51 +139,40 @@ llxHeader('',$title,$help_url); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) + +if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); +//if ($res < 0) { dol_print_error($db); exit; } + + +$head = societe_prepare_head($object); + +dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); + +dol_fiche_end(); + +print '
'; + +if ($action != 'presend') { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template -} -else -{ - - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); - //if ($res < 0) { dol_print_error($db); exit; } - - - $head = societe_prepare_head($object); - - dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); - - dol_fiche_end(); - - print '
'; - - if ($action != 'presend') + // Contacts list + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - // Contacts list - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } } + // End of page llxFooter(); $db->close(); From f074daae4800882a53acbc726673b352c0b9ca4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 May 2018 20:17:31 +0200 Subject: [PATCH 180/183] Fix option MAIN_MAIL_ENABLED_USER_DEST_SELECT --- htdocs/core/actions_sendmails.inc.php | 23 ++++++++++++----------- htdocs/core/class/html.formmail.class.php | 6 +++--- htdocs/langs/en_US/mails.lang | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f751711288c..8c81c0efc6a 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -146,9 +146,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtocc=''; $sendtobcc=''; $sendtoid = array(); - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { - $sendtouserid=array(); - } + $sendtouserid=array(); + $sendtoccuserid=array(); // Define $sendto $receiver=$_POST['receiver']; @@ -179,18 +178,20 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { $receiveruser=$_POST['receiveruser']; if (is_array($receiveruser) && count($receiveruser)>0) { $fuserdest = new User($db); foreach($receiveruser as $key=>$val) { - $tmparray[] = $fuserdest->user_get_property($key,'email'); - $sendtouserid[] = $key; + $tmparray[] = $fuserdest->user_get_property($val,'email'); + $sendtouserid[] = $val; } } } + $sendto=implode(',',$tmparray); // Define $sendtocc @@ -222,15 +223,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { - $receiveruser=$_POST['receiveccruser']; + $receiverccuser=$_POST['receiverccuser']; - if (is_array($receiveruser) && count($receiveruser)>0) + if (is_array($receiverccuser) && count($receiverccuser)>0) { $fuserdest = new User($db); - foreach($receiveruser as $key=>$val) + foreach($receiverccuser as $key=>$val) { - $tmparray[] = $fuserdest->user_get_property($key,'email'); - $sendtouserid[] = $key; + $tmparray[] = $fuserdest->user_get_property($val,'email'); + $sendtoccuserid[] = $val; } } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 555ad503693..5beae12a4fb 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -632,7 +632,7 @@ class FormMail extends Form if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $out.= '
'.$langs->trans("MAIN_PROXY_HOST").''; print ''; @@ -172,7 +169,7 @@ print '
'.$langs->trans("MAIN_PROXY_PORT").''; print ''; @@ -181,7 +178,7 @@ print '
'.$langs->trans("MAIN_PROXY_USER").''; print ''; @@ -190,7 +187,7 @@ print '
'.$langs->trans("MAIN_PROXY_PASS").''; print ''; From d766cb66b8814588abce4393a20f6b7b56263a8c Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 16:14:41 +0100 Subject: [PATCH 055/183] Overload styles files from a current folder of module & theme --- htdocs/main.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e20451e2415..bd803febe5f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1235,10 +1235,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; //Overload css files to the current theme - // Check if the /theme/nameoftheme/style folder exists and Add the contains css files to head + // Check if the /theme/nameoftheme/style folder exists and add the contains css files to head if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) { - //browse the css dir and add the contains css files + //browse the style dir and add the contains css files if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) { while (false !== ($entry = readdir($handle))) @@ -1254,7 +1254,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } //Overload css files to the current module - // Check if the /module/style folder exists and Add the contains css files to head + // Check if the /module/style folder exists and add the contains css files to head $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); if(is_array($cur_modulepart) && count($cur_modulepart)>0) { From 8e2844b29547a0dd232177c2e299446ff5dac2e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 17:55:29 +0200 Subject: [PATCH 056/183] css --- htdocs/projet/ganttview.php | 2 +- htdocs/projet/tasks.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 248eb1a63b3..2f43701c73d 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -209,7 +209,7 @@ else $linktocreatetask = ''.$langs->trans('AddTask').''; } -$linktolist=''.$langs->trans("GoToListOfTasks").' '; +$linktolist=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktolist.'   '.$linktocreatetask, 'title_generic.png'); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 22fe740a63b..69c62416e9b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -488,7 +488,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $title=$langs->trans("ListOfTasks"); - $linktotasks=''.$langs->trans("GoToGanttView").' '; + $linktotasks=''.$langs->trans("GoToGanttView").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); From 06bad22b31136e8c938aee6ac37bfda8b37f8f31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 18:12:18 +0200 Subject: [PATCH 057/183] FIX function not found --- htdocs/product/class/product.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f36fd59035..f2c59f95925 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3514,6 +3514,7 @@ class Product extends CommonObject } if (! empty($conf->accounting->enabled) && $this->status_buy) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); } if (! empty($this->entity)) From 634e58b7c97a3d48ac8559eb801fa95b1b81ce60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 18:12:18 +0200 Subject: [PATCH 058/183] Look and feel v8 --- htdocs/admin/agenda_reminder.php | 6 +----- htdocs/product/class/product.class.php | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index fac49dcfcde..76b69073f25 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("other"); -$langs->load("agenda"); +$langs->loadLangs(array("admin","other","agenda")); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); @@ -173,8 +171,6 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print "
\n"; - diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f36fd59035..f2c59f95925 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3514,6 +3514,7 @@ class Product extends CommonObject } if (! empty($conf->accounting->enabled) && $this->status_buy) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); } if (! empty($this->entity)) From e34bd1a2228443faa0f45884669b37e87b237c73 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 18:08:04 +0100 Subject: [PATCH 059/183] Update llx_entrepot add model_pdf --- htdocs/install/mysql/tables/llx_entrepot.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index cfb17c55766..4c6f0480d5a 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -34,6 +34,7 @@ create table llx_entrepot fk_pays integer DEFAULT 0, statut tinyint DEFAULT 1, -- 1 open, 0 close fk_user_author integer, - import_key varchar(14), + model_pdf varchar(255), + import_key varchar(14), fk_parent integer DEFAULT 0 )ENGINE=innodb; From 468f970d32a41150ffd03117f1dc89b6650fe3b7 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 18:10:55 +0100 Subject: [PATCH 060/183] Update llx_stock_mouvement Add model_pdf --- htdocs/install/mysql/tables/llx_stock_mouvement.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement.sql b/htdocs/install/mysql/tables/llx_stock_mouvement.sql index 3ac42c0c852..1e78e7a9820 100644 --- a/htdocs/install/mysql/tables/llx_stock_mouvement.sql +++ b/htdocs/install/mysql/tables/llx_stock_mouvement.sql @@ -34,5 +34,6 @@ create table llx_stock_mouvement label varchar(255), -- Comment on movement inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking) fk_origin integer, - origintype varchar(32) + origintype varchar(32), + model_pdf varchar(255) )ENGINE=innodb; From 1b2dbedd154b6e1849985294b3fba8f31aefc9d6 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 22:06:44 +0100 Subject: [PATCH 061/183] Add models pdf to warehouse module - Warehouse report - Mouvement report From f6ca1eb6248e022288a32d25a1c0fa9c53cda556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:24:46 +0200 Subject: [PATCH 062/183] Fix permission name --- htdocs/core/menus/standard/eldy.lib.php | 24 ++++++++++++------------ htdocs/core/modules/modStock.class.php | 10 +++++----- htdocs/product/inventory/card.php | 6 +++--- htdocs/product/inventory/list.php | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e930a0ab8b9..171c2a52f8d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1257,18 +1257,18 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->stock->enabled)) { $langs->load("stocks"); - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); - } - else - { - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->write); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); - } + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); + } + else + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->inventory_advance->read, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->inventory_advance->write); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->inventory_advance->read); + } } } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index c23a02eeac1..daeb948fe4a 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -122,31 +122,31 @@ class modStock extends DolibarrModules $this->rights[5][0] = 1011; $this->rights[5][1] = 'inventoryReadPermission'; // Permission label $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[6][0] = 1012; $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[6][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[7][0] = 1013; $this->rights[7][1] = 'inventoryWritePermission'; // Permission label $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[8][0] = 1014; $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label $this->rights[8][3] = 0; // Permission by default for new user (0/1) - $this->rights[8][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][0] = 1015; $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label $this->rights[9][3] = 0; // Permission by default for new user (0/1) - $this->rights[9][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 30bb3312576..aaba9e8cdfe 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -42,7 +42,7 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $result = restrictedArea($user, 'stock', $id, '', 'advance_inventory'); + $result = restrictedArea($user, 'stock', $id, '', 'inventory_advance'); } // Initialize technical objects @@ -82,8 +82,8 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $permissiontoadd = $user->rights->stock->advance_inventory->create; - $permissiontodelete = $user->rights->stock->advance_inventory->write; + $permissiontoadd = $user->rights->stock->inventory_advance->create; + $permissiontodelete = $user->rights->stock->inventory_advance->write; } diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index f3089099efe..79f0835e991 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -78,7 +78,7 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); + $result = restrictedArea($user, 'stock', $objectid, '', 'inventory_advance'); } // Initialize array of search criterias From a9c7f905121083354b7b04d4a300c9be87a40c4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:36:20 +0200 Subject: [PATCH 063/183] Missing hook after deprecated trigger --- htdocs/user/logout.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 5958c71f295..ceeaf35fddf 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -48,6 +48,13 @@ $result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf); if ($result < 0) { $error++; } // Fin appel triggers +// Hooks on logout +$action=''; +$hookmanager->initHooks(array('logout')); +$parameters=array(); +$reshook=$hookmanager->executeHooks('afterLogout',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { $error++; } + // Define url to go after disconnect $urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"]; From bdf4c0704b52c306cf75972573eb8ae3a514ef83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:40:45 +0200 Subject: [PATCH 064/183] Removed depreaceted not used method Categorie::get_nb_categories() --- ChangeLog | 2 +- htdocs/categories/class/categorie.class.php | 24 --------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19ab1e0f49b..b800098144b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,7 +21,7 @@ Following changes may create regressions for some external modules, but were nec * Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. * The hook contaxt commcard has been renamed thirdpartycomm * The hook contaxt thirdpartycard has been renamed thirdpartycontact - +* Remove method Categorie:get_nb_categories() that was not used. ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5fa8d267830..0f28a8d1cde 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1207,30 +1207,6 @@ class Categorie extends CommonObject } } - /** - * Returns total number of categories - * - * @return int Number of categories - * @deprecated function not used ? - */ - function get_nb_categories() - { - $sql = "SELECT count(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - $res = $this->db->query($sql); - if ($res) - { - $res = $this->db->fetch_array($res); - return $res[0]; - } - else - { - dol_print_error($this->db); - return -1; - } - } - /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * From 363eaf0d72196120bb9af4ff96f97cccbb71a6c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:44:49 +0200 Subject: [PATCH 065/183] FIX Parameters to triggers must be set into $this->context array. --- htdocs/categories/class/categorie.class.php | 6 ++---- ...interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 0f28a8d1cde..044f3e68c0f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -761,11 +761,9 @@ class Categorie extends CommonObject dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { - // Save object we want to unlink category off into category instance to provide information to trigger - $this->unlinkoff=$obj; - // Call trigger - $result=$this->call_trigger('CATEGORY_UNLINK',$user); + $this->context=array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_UNLINK',$user); if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index 44a6645a6d7..c5f704fdcb1 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -75,10 +75,10 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) - if (is_object($object->unlinkoff) && method_exists($object->unlinkoff, 'del_to_abo') && $object->unlinkoff->del_to_abo() < 0) + if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) { - $this->error=$object->unlinkoff->error; - $this->errors=$object->unlinkoff->errors; + $this->error=$object->context['unlinkoff']->error; + $this->errors=$object->context['unlinkoff']->errors; $return=-1; } else From 17b8de2cdd420a33629c2ee8848e5397a8bcce6d Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Sat, 5 May 2018 12:52:38 +0100 Subject: [PATCH 066/183] New : Option INVOICE_CAN_REMOVE_DRAFT_ONLY to delete draft invoices with precedence over INVOICE_CAN_ALWAYS_BE_REMOVED --- htdocs/compta/facture/list.php | 34 ++++++++++++------------- htdocs/core/actions_massactions.inc.php | 28 +++++++------------- htdocs/core/tpl/massactions_pre.tpl.php | 5 ++++ htdocs/langs/en_US/main.lang | 4 ++- htdocs/langs/fr_FR/main.lang | 2 ++ 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 29a98c0541b..c90ab660c31 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -585,24 +585,22 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); - if ($conf->prelevement->enabled) - { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest']=$langs->trans("MakeWithdrawRequest"); - } - if ($user->rights->facture->supprimer) - { - //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - { - // mass deletion never possible on invoices on such situation - } - else - { - $arrayofmassactions['predelete']=$langs->trans("Delete"); - } - } - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + if ($conf->prelevement->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); + } + if ($user->rights->facture->supprimer) { + //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) + if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + + } + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { + // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c2c3467e55c..1952bb0c224 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1079,26 +1079,16 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == $result=$objecttmp->fetch($toselectid); if ($result > 0) { - // Refuse deletion for some status ? - /* - if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT) - { - $langs->load("errors"); - $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; - continue; - }*/ + if ($objectclass != 'Facture' || empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) || (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) && $objecttmp->statut == Facture::STATUS_DRAFT) ) { + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + else $result = $objecttmp->delete($user); - if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); - - if ($result <= 0) - { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - else $nbok++; + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } } else { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 48989b2daec..d46e27e28af 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -27,6 +27,11 @@ // $trackid='ord'.$object->id; +if ($massaction == 'predeletedraft') +{ + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDraftDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); +} + if ($massaction == 'predelete') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 418042f1da9..60369b80ea5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -941,4 +941,6 @@ Local=Local Remote=Remote LocalAndRemote=Local and Remote KeyboardShortcut=Keyboard shortcut -AssignedTo=Assigned to \ No newline at end of file +AssignedTo=Assigned to +Deletedraft=Delete draft +ConfirmMassDraftDeletion=Draft Bulk delete confirmation diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index e8681e72e62..6fba224525e 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -941,3 +941,5 @@ Remote=Distant LocalAndRemote=Local et distant KeyboardShortcut=Raccourci clavier AssignedTo=Assigné à +Deletedraft=Supprimer brouillon +ConfirmMassDraftDeletion=Confirmation de suppression brouillons en masse From aba2ef7ad290b239dc87324625c611874bebc0c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:22:18 +0200 Subject: [PATCH 067/183] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1952bb0c224..e1d862b6098 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1079,16 +1079,24 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == $result=$objecttmp->fetch($toselectid); if ($result > 0) { - if ($objectclass != 'Facture' || empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) || (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) && $objecttmp->statut == Facture::STATUS_DRAFT) ) { - if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); + // Refuse deletion for some objects/status + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; + continue; + } + + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + else $result = $objecttmp->delete($user); + + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } } else { From 8baa529719d2352ed98ffadd896b311a665e0a5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:22:52 +0200 Subject: [PATCH 068/183] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e1d862b6098..4d2b6145990 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1091,12 +1091,13 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); - if ($result <= 0) { + if ($result <= 0) + { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; - + } + else $nbok++; } else { From 97f161b2763767ae376760f2e4922a8e65c85150 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:25:44 +0200 Subject: [PATCH 069/183] Update list.php --- htdocs/compta/facture/list.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c90ab660c31..b6bde6605ad 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -585,22 +585,19 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); - if ($conf->prelevement->enabled) { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); - } - if ($user->rights->facture->supprimer) { - //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { - $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); - - } - elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { - // mass deletion never possible on invoices on such situation - $arrayofmassactions['predelete'] = $langs->trans("Delete"); - } - } - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($conf->prelevement->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); + } + if ($user->rights->facture->supprimer) { + if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + } + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; From a8ecce9e6d1d8e550833f69c285ebb9ce0f7bc54 Mon Sep 17 00:00:00 2001 From: altatof Date: Sat, 5 May 2018 14:31:17 +0200 Subject: [PATCH 070/183] add hook for more permissions control --- htdocs/core/lib/security.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 4cfc077f0be..15047b2f2d7 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -331,10 +331,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - return $ok ? 1 : accessforbidden(); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) + accessforbidden(); } + // get more permissions checks from hooks + global $hookmanager; + $hookmanager->initHooks(array('permissions')); + $parameters=array('features'=>$features,'objectid'=>preg_replace("/'/", '', $objectid),'idtype'=>$dbt_select); + $reshook=$hookmanager->executeHooks('restricted',$parameters); + if ($reshook < 0) accessforbidden(); + return 1; } From c2696996791a72e05db356035512902a4143bbd4 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sat, 5 May 2018 13:33:34 +0100 Subject: [PATCH 071/183] Add model_pdf to warehouse module --- htdocs/core/modules/modStock.class.php | 83 ++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ca518ed8851..2cb53a52da4 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -60,7 +60,7 @@ class modStock extends DolibarrModules $this->picto='stock'; // Data directories to create when module is enabled - $this->dirs = array(); + $this->dirs = array("/stock/temp"); $this->config_page_url = array("stock.php"); @@ -70,9 +70,38 @@ class modStock extends DolibarrModules $this->langfiles = array("stocks"); // Constants - $this->const = array( - 0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1) - ); + $this->const = array(); + $r=0; + + $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1); + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "Standard"; + $this->const[$r][3] = 'Name of PDF model of stock'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "StdMouvement"; + $this->const[$r][3] = 'Name of PDF model of stock mouvement'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; // Boxes $this->boxes = array(); @@ -266,4 +295,50 @@ class modStock extends DolibarrModules ); } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + global $conf,$langs; + + // Permissions + $this->remove($options); + + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/stock'; + $dest=$dirodt.'/template_stock.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array(); + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")", + ); + + return $this->_init($sql,$options); + } } From fb81088a4b8b9de12faa7923176c2ba23e3a6e2c Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sat, 5 May 2018 13:44:11 +0100 Subject: [PATCH 072/183] Add models warehouse and movement --- htdocs/core/modules/stock/modules_stock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/stock/modules_stock.class.php b/htdocs/core/modules/stock/modules_stock.class.php index 9af3aa11501..283ae75b6a3 100644 --- a/htdocs/core/modules/stock/modules_stock.class.php +++ b/htdocs/core/modules/stock/modules_stock.class.php @@ -81,7 +81,7 @@ abstract class ModelePDFMouvement extends CommonDocGenerator { global $conf; - $type='mouvementcom'; + $type='mouvement'; $liste=array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $liste=getListOfModels($db,$type,$maxfilenamelength); From c34bfc229b9b90088c0cb183a897f3573aee24fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 19:39:58 +0200 Subject: [PATCH 073/183] Fix syntax error --- htdocs/core/actions_massactions.inc.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4d2b6145990..371dd75a8e2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1080,18 +1080,18 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == if ($result > 0) { // Refuse deletion for some objects/status - if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)) - { - $langs->load("errors"); - $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; - continue; - } - + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; + continue; + } + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); - if ($result <= 0) + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; From b958311819231c32d329e96a9d90bf869d49187b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 20:25:06 +0200 Subject: [PATCH 074/183] Prepare 6.0.7 --- ChangeLog | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dcc363d03a9..405aaa9ed9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,22 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 6.0.6 compared to 6.0.6 ***** +***** ChangeLog for 6.0.7 compared to 6.0.6 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: actioncomm export: type filtering not working +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: issue #8037 +FIX: label in getnomurl projectlist +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 !! +FIX: some localtaxes errors +FIX: weird password autocompletion in Google Chrome (issue #8479) + +***** ChangeLog for 6.0.6 compared to 6.0.5 ***** FIX: #7974 Contract - Invalid reference on the document FIX: #8139 FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php From d4d4f8cc832785b416cf38952272ee32b15c383f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 20:29:06 +0200 Subject: [PATCH 075/183] Prepare 7.0.2 --- ChangeLog | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3ecdc4d0c54..0a2157316b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,96 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 7.0.2 compared to 7.0.1 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8359 +FIX: #8389 +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: #8559 Bug to generate cheque receipt +FIX: #8571 +FIX: #8574 +FIX: #8580 +FIX: #8650 +FIX: actioncomm export: type filtering not working +FIX: Add a test to avoid to reset binding by error. +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: Add warning when expense report line not into range +FIX: avoid Error: Call to undefined method mysqli::get_charset() +FIX: avoid focus problem when select2 is in a modal dialog window +FIX: Binding pages must start on fiscal month not calendar month +FIX: button "Classify bill" on supplier order was not visible +FIX: Button receive products not visible +FIX: can bypass the CSRF protection with url with domain inside +FIX: Can't edit option PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY +FIX: commonobject: don't require notnull field if default set +FIX: CommonObject: don't require 'notnull' field if 'default' set +FIX: cron script disabled if module disabled +FIX: CVE-2018-10092 +FIX: CVE-2018-10094 +FIX: CVE-2018-10095 +FIX: CVE-2018-9019 +FIX: CWE-89 +FIX: Data on income/expense report was always 0 +FIX: default addupdatedelete actions: uniformize add/update value checks +FIX: default currency not set on supplier order creation from commercial menu #8459 +FIX: delete all product variants of a parent product +FIX: Detail per account not visible when total < 0 +FIX: DOL_AUTOSET_COOKIE was not correctly setting value of cookie +FIX: don't print empty date in CommonObject::showOutputField +FIX: dont print empty date in CommonObject::showOutputField +FIX: Draft invoice must be excluded from report +FIX: environment shown on cron card +FIX: Error in ContractLigne not return to Contract +FIX: extrafields price and double were lost during a failed post. +FIX: File name not visible in email preview +FIX: filter/sorting on extrafield on contact list from contact tab +FIX: Initial month on report income/expense per predefined group +FIX: issue #8037 +FIX: Issue #8455 +FIX: issue #8470 +FIX: label in getnomurl projectlist +FIX: limit access of email template page to internal users +FIX: look and feel v7 "back to" for bookkeeping record +FIX: Max nb of generation of recurring invoice should not show warning +FIX: missing english name for object +FIX: Missing include +FIX: missing User object with API REST +FIX: modulebuilder: could not create html fields +FIX: modulebuilder: handle 'price' fieldtype +FIX: multiple creation of same event +FIX: Name of user not visible on journalizing expense report payments +FIX: Not approved holidays must not be visible into timesheet +FIX: Only approved expense report must be journalized +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 +FIX: Projet is not prefilled when created from overwiew page +FIX: Related contact printed in societe agenda +FIX: Removed error when no error on accounting setup page +FIX: remove var_dump +FIX: sanitize setup params +FIX: selectForFormsList: entity checked even is object not multi-entity managed +FIX: service creation, right is tested regarding the product type +FIX: some localtaxes errors +FIX: Some report have data when several chart of accounts exists +FIX: sql error using no category +FIX: SQL Injection CWE-89 +FIX: Support or multicompany for sheduled jobs +FIX: Test on mandatory status when closing proposal failed +FIX: to allow IRPF not null even if main VAT is null. +FIX: update wrong datetime extrafield +FIX: Use priority to define order of sheduled jobs +FIX: various modulebuilder-related issues +FIX: view of balance before field +FIX: weird password autocompletion in Goocle Chrome (issue #8479) +FIX: weird password autocompletion in Google Chrome (issue #8479) +FIX: When clearing filter, we must not save tmp criterias in session +FIX: With x extrafields, request for multicompany label was done x times +FIX: several XSS +FIX: zip not filtered + ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php FIX: #8200 From f76df85aec7a18ce137e8f1ef6d9e8629cc93194 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 21:53:02 +0200 Subject: [PATCH 076/183] compatibility with ubuntu 14.04 --- build/makepack-dolibarr.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 7da6d180dcb..62e1b8b6c34 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -849,6 +849,8 @@ if ($nboftargetok) { unlink("$NEWDESTI/${FILENAMEDEB}.changes"); print "Remove target ${FILENAMEDEB}.debian.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.gz"); + print "Remove target ${FILENAMEDEB}.debian.tar.xz...\n"; + unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.xz"); print "Remove target ${FILENAMEDEBNATIVE}.orig.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEBNATIVE}.orig.tar.gz"); @@ -1024,7 +1026,8 @@ if ($nboftargetok) { $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.orig.tar.gz "$NEWDESTI/"`; - $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/"`; + $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/" 2>/dev/null`; + $ret=`mv $BUILDROOT/*.debian.tar.xz "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`; next; } From 19008531bba77484b3fbbe1fefdc5eaf81efffbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 21:56:34 +0200 Subject: [PATCH 077/183] Fix packager --- build/makepack-dolibarr.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 62e1b8b6c34..31338e44649 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -466,10 +466,12 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.dsc`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tgz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.zip`; @@ -1026,7 +1028,6 @@ if ($nboftargetok) { $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.orig.tar.gz "$NEWDESTI/"`; - $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/" 2>/dev/null`; $ret=`mv $BUILDROOT/*.debian.tar.xz "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`; next; @@ -1171,7 +1172,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'none', # none means it won't be published on SF - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'none', # none means it won't be published on SF + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', # none means it won't be published on SF "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)', "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', @@ -1184,8 +1185,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', From f15da0b980f8c3ed6862d45a654f0ba8ccbe8acf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:15:19 +0200 Subject: [PATCH 078/183] Fix chart of account initial data for syscohada --- .../install/mysql/migration/6.0.0-7.0.0.sql | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index efb47ede029..cf0a8c8cc49 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -577,21 +577,21 @@ ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile( -- Add new chart of account entries INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 67,'PC-MIPYME', 'The PYME accountancy Chile plan', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 7,'ENG-BASE', 'England plan', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA-BJ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA-BF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA-CM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA-CF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA-KM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA-CG', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA-CI', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA-GA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA-GQ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA-ML', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA-NE', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA-CD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA-SN', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA-TD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA-TG', 'Plan comptable Ouest-Africain', 1); -- Update old chart of account entries From 7511ba52ae301ca0cfdc1845b6c131a625a13673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:20:33 +0200 Subject: [PATCH 079/183] NEW Suggest link to pay online for customer orders --- htdocs/commande/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d399c83131c..57b98d1a29a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2613,9 +2613,8 @@ if ($action == 'create' && $user->rights->commande->creer) $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - //$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); - $useonlinepayment = $conf->global->ORDER_SHOW_ONLINE_PAYMENT_ON_ORDER; - + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + if (! empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { print '
'; From fd53788d2f657064efad986eb2778b0b1a52715c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:54:22 +0200 Subject: [PATCH 080/183] Add param autostable into generate_filelist_xml.php --- build/generate_filelist_xml.php | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 5f54c95d7e0..86afcd286f9 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -45,7 +45,7 @@ $includeconstants=array(); if (empty($argv[1])) { - print "Usage: ".$script_file." release=auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + print "Usage: ".$script_file." release=autostable|auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; exit -1; } @@ -68,29 +68,44 @@ while ($i < $argc) $i++; } +$savrelease = $release; + // If release is auto, we take current version $tmpver=explode('-', $release, 2); -if ($tmpver[0] == 'auto') +if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') { $release=DOL_VERSION; - if ($tmpver[1]) $release.='-'.$tmpver[1]; + if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1]; } if (empty($includecustom)) { - $tmpver=explode('-', $release, 2); - if (DOL_VERSION != $tmpver[0]) - { - print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpver[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; - exit -1; - } + $tmpverbis=explode('-', $release, 2); + if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') + { + if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') + { + print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + exit -1; + } + } + else + { + $tmpverter=explode('-', DOL_VERSION, 2); + if ($tmpverter[0] != $tmpverbis[0]) + { + print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + exit -1; + } + } } else { if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release)) { - print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parmater (ex: '.DOL_VERSION.'-mydistrib).'."\n"; + print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n"; print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; exit -1; } From 8e729c2021f885274e7be81cf32e73897baa907b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 23:12:31 +0200 Subject: [PATCH 081/183] Add param autostable into generate_filelist_xml.php --- build/generate_filelist_xml.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 86afcd286f9..93ee76e3359 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -45,7 +45,7 @@ $includeconstants=array(); if (empty($argv[1])) { - print "Usage: ".$script_file." release=autostable|auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; exit -1; } @@ -68,6 +68,13 @@ while ($i < $argc) $i++; } +if (empty($release)) +{ + print "Error: Missing release paramater\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + exit -1; +} + $savrelease = $release; // If release is auto, we take current version @@ -86,7 +93,7 @@ if (empty($includecustom)) if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') { print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } @@ -96,7 +103,7 @@ if (empty($includecustom)) if ($tmpverter[0] != $tmpverbis[0]) { print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } @@ -106,7 +113,7 @@ else if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release)) { print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } From a84217868923b1c38e774483bf4bacb800431145 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 23:20:53 +0200 Subject: [PATCH 082/183] Fix migration missing steps --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 3ca87e97053..055a38a36b7 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -59,6 +59,24 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 10, 'PCT', 'The Tunisia plan', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 12, 'PCG', 'The Moroccan chart of accounts', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 67,'PC-MIPYME', 'The PYME accountancy Chile plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 7,'ENG-BASE', 'England plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA-BJ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA-BF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA-CM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA-CF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA-KM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA-CG', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA-CI', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA-GA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA-GQ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA-ML', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA-NE', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA-CD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA-SN', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA-TD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA-TG', 'Plan comptable Ouest-Africain', 1); + -- For 8.0 -- delete old permission no more used From 20c50e809d848a335195df76d54b82964ebd7e18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 May 2018 10:43:40 +0200 Subject: [PATCH 083/183] Start 6.0.8 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 7f5b0f5e746..9ab5de809b9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.7'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.8'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From a2c93e56aef79e40ec0d35ccc3987442bba7178c Mon Sep 17 00:00:00 2001 From: delcroix Patrick Date: Sun, 6 May 2018 13:36:37 +0200 Subject: [PATCH 084/183] fixAdd properly the project models Previous code was adding only the Task model (project model where actually push during the installation) and only one of the two model available. --- htdocs/core/modules/modProjet.class.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index ab837803349..d38fc743de1 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -352,15 +352,14 @@ class modProjet extends DolibarrModules } } - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'project' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','project',".$conf->entity.")", - ); - - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")" - ); + $sql = array(); + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")"; + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")"; + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")"; + return $this->_init($sql,$options); } From 5ac2b515174d2b5825e686db777c85947fc4da66 Mon Sep 17 00:00:00 2001 From: delcroix Patrick Date: Sun, 6 May 2018 17:29:30 +0200 Subject: [PATCH 085/183] new: log message for missing traduction It's often difficult to find out the missing translation --- htdocs/core/class/translate.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0df169a3c3e..ec3ed00a313 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -576,6 +576,7 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } + dol_syslog(__METHOD__."missing translation ".$newstr." in ".$_SERVER["PHP_SELF"], LOG_DEBUG); return $newstr; } From c90d0e6cb35a6b4dd084708a4f727fd2d1a28591 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sun, 6 May 2018 17:30:54 +0100 Subject: [PATCH 086/183] Add pdf warehouse to warehouse module From e733ea29791c2c26c7ea96400399a4e6502a3780 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sun, 6 May 2018 17:54:59 +0100 Subject: [PATCH 087/183] Revert "Add models pdf to warehouse module" From de8bd3f8868aa3b72f4d4e00b29b46bdea455c20 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 7 May 2018 08:31:40 +0100 Subject: [PATCH 088/183] New : Translate accountancy journal menu entries --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- htdocs/install/mysql/data/llx_accounting_abc.sql | 14 +++++++------- htdocs/langs/en_US/accountancy.lang | 5 ++++- htdocs/langs/fr_FR/accountancy.lang | 4 +++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3d05ac3ceb3..4d3951f7b5e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1069,7 +1069,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($nature) { - $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, dol_trunc($objp->label,25), 2, $user->rights->accounting->comptarapport->lire); + $langs->load('accountancy'); + $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $langs->trans($objp->label), 2, $user->rights->accounting->comptarapport->lire); } $i++; } diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 6345768e6a8..e80de82b6ad 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -29,13 +29,13 @@ -- -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'Sale Journal', 2, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'Purchase Journal', 3, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'Bank Journal', 4, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'Other Journal', 1, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'Has new Journal', 9, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'Expense Report Journal', 5, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'Inventory Journal' , 8, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal' , 8, 1, 1); -- Description of chart of account FR PCG99-ABREGE diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index f3acb7ac39c..a7b7e345682 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -137,6 +137,7 @@ ACCOUNTING_PURCHASE_JOURNAL=Purchase journal ACCOUNTING_MISCELLANEOUS_JOURNAL=Miscellaneous journal ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal +ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait @@ -294,4 +295,6 @@ Binded=Lines bound ToBind=Lines to bind UseMenuToSetBindindManualy=Autodection not possible, use menu %s to make the binding manually -WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. +ExpenseReportJournal=Expense Report Journal +InventoryJournal=Inventory Journal diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 0bb7e235410..2ff8dc59dd9 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -133,9 +133,10 @@ BANK_DISABLE_DIRECT_INPUT=Désactiver la saisie directe de transactions en banqu ACCOUNTING_SELL_JOURNAL=Journal des ventes ACCOUNTING_PURCHASE_JOURNAL=Journal des achats -ACCOUNTING_MISCELLANEOUS_JOURNAL=Journal des opérations diverses +ACCOUNTING_MISCELLANEOUS_JOURNAL=Journal des ops. diverses ACCOUNTING_EXPENSEREPORT_JOURNAL=Journal des notes de frais ACCOUNTING_SOCIAL_JOURNAL=Journal de paie +ACCOUNTING_HAS_NEW_JOURNAL=Journal d'ouverture ACCOUNTING_ACCOUNT_TRANSFER_CASH=Compte comptable de tranfert ACCOUNTING_ACCOUNT_SUSPENSE=Compte comptable d'attente @@ -294,3 +295,4 @@ ToBind=Lignes à lier UseMenuToSetBindindManualy=L'autodection n'est pas possible, utilisez le menu %s pour effectuer la liaison manuellement WarningReportNotReliable=Attention : ce rapport n'est pas basé sur le grand livre et ne contient donc pas les écritures manuelles qui lui ont été ajoutées. Si votre journalisation est à jour, la vue depuis le grand livre sera plus précise. +InventoryJournal=Journal d'inventaire From fd9b6365a76883b487870225d36df6a90c06e038 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 7 May 2018 09:19:45 +0100 Subject: [PATCH 089/183] New : Translate list element in journal selection --- htdocs/core/class/html.formaccounting.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 18cf165e641..17e437f5223 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -64,7 +64,7 @@ class FormAccounting extends Form */ function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { - global $conf; + global $conf,$langs; $out = ''; @@ -93,9 +93,10 @@ class FormAccounting extends Form } $selected = 0; + $langs->load('accountancy'); while ($obj = $this->db->fetch_object($resql)) { - $label = $obj->code . ' - ' . $obj->label; + $label = $obj->code . ' - ' . $langs->trans($obj->label); $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; From 5bc9799bf1d48e232cd8b11d430b974264b88331 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 7 May 2018 16:30:22 +0200 Subject: [PATCH 090/183] FIX : Drag and drop lines with extrafields --- htdocs/core/tpl/ajaxrow.tpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 070eefc0ff0..4ae64ea82ed 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -55,6 +55,7 @@ $(document).ready(function(){ var reloadpage = ""; console.log("tableDND onDrop"); console.log(decodeURI($("#").tableDnDSerialize())); + $('# tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function var roworder = cleanSerialize(decodeURI($("#").tableDnDSerialize())); var table_element_line = ""; var fk_element = ""; From fb9ace010fdb0e07ef0c8cd75f31f7fa4224ec05 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 7 May 2018 17:16:20 +0200 Subject: [PATCH 091/183] FIX : Missing translations --- htdocs/langs/en_US/categories.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 8b38b2f1f42..c0c8d4c0cef 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -85,3 +85,4 @@ CategorieRecursivHelp=If activated, product will also linked to parent category AddProductServiceIntoCategory=Add the following product/service ShowCategory=Show tag/category ByDefaultInList=By default in list +ChooseCategory=Choose category From d1fd39936c8079dc642231fe54ff2a2265b91223 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 8 May 2018 09:04:04 +0200 Subject: [PATCH 092/183] Fix: Bug on invoice status list on left menu --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 171c2a52f8d..0104f787bf8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2012-2015 Juanjo Menent * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -802,7 +803,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire, '', $mainmenu, 'customers_bills_list'); - if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|draft|notpaid|paid|canceled)$/', $leftmenu)) + if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) { $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&search_status=0",$langs->trans("BillShortStatusDraft"),2,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&search_status=1",$langs->trans("BillShortStatusNotPaid"),2,$user->rights->facture->lire); From 415b7425fdbaadf26e24428f508526f395182931 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 8 May 2018 09:45:10 +0200 Subject: [PATCH 093/183] NEW add pdf function to check if pdf file is protected/encrypted --- htdocs/core/lib/pdf.lib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e2c01f90f47..b0cda2ecd6a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -169,6 +169,25 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') return $pdf; } +/** + * Return if pdf file is protected/encrypted + * + * @param TCPDF $pdf PDF initialized object + * @param string $pathoffile Path of file + * @return boolean True or false + */ +function pdf_getEncryption(&$pdf, $pathoffile) +{ + $isencrypted = false; + + $pdfparser = $pdf->_getPdfParser($pathoffile); + $data = $pdfparser->getParsedData(); + if (isset($data[0]['trailer'][1]['/Encrypt'])) { + $isencrypted = true; + } + + return $isencrypted; +} /** * Return font name to use for PDF generation From 70527e64c51be73c1e621b33682cc76c6df5e1b2 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 8 May 2018 18:15:02 +0200 Subject: [PATCH 094/183] New: Add Date delivery and Availability on Propals List --- htdocs/comm/propal/list.php | 102 +++++++++++++++++++++++++- htdocs/core/class/html.form.class.php | 3 +- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d5d155ce0bf..ced465dfdb7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI * @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->loadLangs(array('companies','propal','compta','bills','orders','products')); +$langs->loadLangs(array('companies','propal','compta','bills','orders','products','deliveries')); $socid=GETPOST('socid','int'); @@ -76,6 +76,13 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_dayfin=GETPOST("search_dayfin","int"); +$search_monthfin=GETPOST("search_monthfin","int"); +$search_yearfin=GETPOST("search_yearfin","int"); +$search_daydelivery=GETPOST("search_daydelivery","int"); +$search_monthdelivery=GETPOST("search_monthdelivery","int"); +$search_yeardelivery=GETPOST("search_yeardelivery","int"); +$search_availability=GETPOST('search_availability','int'); $search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $viewstatut=GETPOST('viewstatut','alpha'); @@ -145,6 +152,8 @@ $arrayfields=array( 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), + 'p.date_livraison'=>array('label'=>$langs->trans("DeliveryDate"), 'checked'=>0), + 'ava.rowid'=>array('label'=>$langs->trans("AvailabilityPeriod"), 'checked'=>0), 'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), @@ -202,6 +211,13 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_year=''; $search_month=''; $search_day=''; + $search_yearfin=''; + $search_monthfin=''; + $search_dayfin=''; + $search_yeardelivery=''; + $search_monthdelivery=''; + $search_daydelivery=''; + $search_availability=''; $viewstatut=''; $object_statut=''; $toselect=''; @@ -245,8 +261,9 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; +$sql.= " ava.rowid as availability,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -271,6 +288,7 @@ if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.' if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -292,6 +310,7 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer); if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet); +if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); @@ -323,6 +342,32 @@ else if ($search_year > 0) { $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } +if ($search_monthfin > 0) +{ + if ($search_yearfin > 0 && empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'"; + else if ($search_yearfin > 0 && ! empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'"; + else + $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'"; +} +else if ($search_yearfin > 0) +{ + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,1,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,12,false))."'"; +} +if ($search_monthdelivery > 0) +{ + if ($search_yeardelivery > 0 && empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,$search_monthdelivery,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,$search_monthdelivery,false))."'"; + else if ($search_yeardelivery > 0 && ! empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."'"; + else + $sql.= " AND date_format(p.date_livraison, '%m') = '".$db->escape($search_monthdelivery)."'"; +} +else if ($search_yeardelivery > 0) +{ + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,1,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,12,false))."'"; +} if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); if ($search_user > 0) { @@ -566,7 +611,32 @@ if ($resql) // Date end if (! empty($arrayfields['p.fin_validite']['checked'])) { - print '
 '; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yearfin,'search_yearfin',1, 20, 5); + print ''; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yeardelivery,'search_yeardelivery',1, 20, 5); + print ''; + print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); + print ajax_combobox('search_availability'); + print ''.dol_print_date($db->jdate($obj->ddelivery),'day'); + print ' '; + $form->form_availability('', $obj->availability, 'none', 1); + print ''; print ''; print ''; + //print ''; + print ''; + // TODO: add new function $formentrepot->selectTypeOfMovement(...) like + // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print ''.$objp->label.''.$objp->type_mouvement.'
'.$langs->trans("User").''; @@ -1358,6 +1359,7 @@ if ($action == 'create') print '
'.$langs->trans("VALIDATOR").''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index e5b35b5a434..18039a1d47e 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -38,7 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; // Get parameters -$myparam = GETPOST("myparam"); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); $fuserid = (GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id); @@ -864,7 +863,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''; - // User + // User for leave request print ''; print ''; print ''; print ''; - // Approved by + // Approver print ''; print ''; print ''; print ''; @@ -1181,7 +1193,13 @@ else print ''; print ''; print ''; print ''; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index f0b36f910d9..03b2491ab59 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1569,6 +1569,48 @@ class Holiday extends CommonObject } } + + /** + * Return list of people with permission to validate leave requests. + * Search for permission "approve leave requests" + * + * @return array Array of user ids + */ + function fetch_users_approver_holiday() + { + $users_validator=array(); + + $sql = "SELECT DISTINCT ur.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql.= "UNION"; + $sql.= " SELECT DISTINCT ugu.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + //print $sql; + + dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); + $result = $this->db->query($sql); + if($result) + { + $num_lignes = $this->db->num_rows($result); $i = 0; + while ($i < $num_lignes) + { + $objp = $this->db->fetch_object($result); + array_push($users_validator,$objp->fk_user); + $i++; + } + return $users_validator; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch_users_approver_holiday Error ".$this->error, LOG_ERR); + return -1; + } + } + + /** * Compte le nombre d'utilisateur actifs dans Dolibarr * From 6b2dfa052811f8cad3059acb3dd9bc3966c2db23 Mon Sep 17 00:00:00 2001 From: atm-john Date: Thu, 10 May 2018 21:06:18 +0200 Subject: [PATCH 114/183] Extend lines import to propal --- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 9 ++++++++- htdocs/compta/facture/card.php | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 004b32a83fc..80db1bf7efc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2278,7 +2278,7 @@ if ($action == 'create') $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer) + if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer && $action != 'selectlines') { if ($action != 'editline') { diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index a13d80c083c..100cabc6023 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -53,7 +53,14 @@ foreach($linkedObjectBlock as $key => $objectlink) if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - + diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dbce9c2e76d..1387765ccc3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2120,9 +2120,14 @@ if (empty($reshook)) { if($fromElement == 'commande') { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class'); + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } + elseif($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; @@ -2164,6 +2169,7 @@ if (empty($reshook)) $pu_ht_devise = $originLine->multicurrency_subprice; $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); + if($res > 0){ $importCount++; }else{ @@ -4534,7 +4540,7 @@ else if ($id > 0 || ! empty($ref)) && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) { - $compatibleImportElementsList = array('commande'); // import from linked elements + $compatibleImportElementsList = array('commande','propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); From e5d8dec2f92b7bf2936429c4dd27da601119fe6c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 11 May 2018 12:18:45 +0200 Subject: [PATCH 115/183] clean and update code --- htdocs/admin/receiptprinter.php | 42 ++++++++++++++++----------------- htdocs/admin/resource.php | 6 ++--- htdocs/admin/security.php | 14 ++--------- htdocs/admin/security_other.php | 11 ++------- htdocs/admin/sms.php | 34 ++++++++------------------ 5 files changed, 36 insertions(+), 71 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 0de8987e277..52141900517 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -30,8 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/receiptprinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; -$langs->load("admin"); -$langs->load("receiptprinter"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","receiptprinter")); if (! $user->admin) accessforbidden(); @@ -232,7 +232,6 @@ if ($mode == 'config' && $user->admin) print $langs->trans("ReceiptPrinterDesc")."

\n"; print '
'.$langs->trans("User").''; @@ -932,11 +931,24 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print '
'.$langs->trans("ReviewedByCP").''; - print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent + + $object = new Holiday($db); + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + else + { + $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + if (! empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver + if (GETPOST('valideur', 'int') > 0) $defaultselectuser=GETPOST('valideur', 'int'); + $s=$form->select_dolusers($defaultselectuser, "valideur", 1, "", 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } + + //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent print '
'.$langs->trans('ReviewedByCP').''; - print $form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + else + { + $s=$form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id)), 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } print '
trans("Proposal"); ?>trans("Proposal"); ?> + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + { + $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; + print ' '; + } + ?> + getNomUrl(1); ?> ref_client; ?> date,'day'); ?>
'."\n"; - $var=true; print ''; print ''; print ''; @@ -248,10 +247,11 @@ if ($mode == 'config' && $user->admin) if ($ret > 0) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { - for ($line=0; $line < $nbofprinters; $line++) { - $var = !$var; + for ($line=0; $line < $nbofprinters; $line++) + { print ''; - if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) { + if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) + { print ''; print ''; $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']); @@ -329,11 +329,11 @@ if ($mode == 'config' && $user->admin) print $langs->trans("ReceiptPrinterTypeDesc")."

\n"; print '
'.$langs->trans("Name").''.$langs->trans("Type").'
'."\n"; - print ''; - print ''; - print ''; - print ''; - //print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; print '
'.$langs->trans("CONNECTOR_DUMMY").':'.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$langs->trans("CONNECTOR_NETWORK_PRINT").':'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'.$langs->trans("CONNECTOR_FILE_PRINT").':'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'
'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'
'.$langs->trans("CONNECTOR_JAVA").':'.$langs->trans("CONNECTOR_JAVA_HELP").'
'.$langs->trans("CONNECTOR_DUMMY").':'.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$langs->trans("CONNECTOR_NETWORK_PRINT").':'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'.$langs->trans("CONNECTOR_FILE_PRINT").':'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'
'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'
'.$langs->trans("CONNECTOR_JAVA").':'.$langs->trans("CONNECTOR_JAVA_HELP").'
'; dol_fiche_end(); @@ -342,11 +342,11 @@ if ($mode == 'config' && $user->admin) dol_fiche_head(); print $langs->trans("ReceiptPrinterProfileDesc")."

\n"; print ''."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans("PROFILE_DEFAULT").':'.$langs->trans("PROFILE_DEFAULT_HELP").'
'.$langs->trans("PROFILE_SIMPLE").':'.$langs->trans("PROFILE_SIMPLE_HELP").'
'.$langs->trans("PROFILE_EPOSTEP").':'.$langs->trans("PROFILE_EPOSTEP_HELP").'
'.$langs->trans("PROFILE_P822D").':'.$langs->trans("PROFILE_P822D_HELP").'
'.$langs->trans("PROFILE_STAR").':'.$langs->trans("PROFILE_STAR_HELP").'
'.$langs->trans("PROFILE_DEFAULT").':'.$langs->trans("PROFILE_DEFAULT_HELP").'
'.$langs->trans("PROFILE_SIMPLE").':'.$langs->trans("PROFILE_SIMPLE_HELP").'
'.$langs->trans("PROFILE_EPOSTEP").':'.$langs->trans("PROFILE_EPOSTEP_HELP").'
'.$langs->trans("PROFILE_P822D").':'.$langs->trans("PROFILE_P822D_HELP").'
'.$langs->trans("PROFILE_STAR").':'.$langs->trans("PROFILE_STAR_HELP").'
'; dol_fiche_end(); } @@ -365,7 +365,6 @@ if ($mode == 'template' && $user->admin) print $langs->trans("ReceiptPrinterTemplateDesc")."

\n"; print ''."\n"; - $var=true; print ''; print ''; print ''; @@ -379,8 +378,8 @@ if ($mode == 'template' && $user->admin) setEventMessages($printer->error, $printer->errors, 'errors'); } else { $max = count($printer->listprinterstemplates); - for ($line=0; $line < $max; $line++) { - $var = !$var; + for ($line=0; $line < $max; $line++) + { print ''; if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) { print ''; @@ -419,14 +418,13 @@ if ($mode == 'template' && $user->admin) print ''; print '

'; print '
'.$langs->trans("Name").''.$langs->trans("Template").'
'."\n"; - $var=true; print ''; print ''; print ''; print "\n"; $max = count($printer->tags); - for ($tag=0; $tag < $max; $tag++) { - $var = !$var; + for ($tag=0; $tag < $max; $tag++) + { print ''; print ''; print ''; diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index 6560d194ca7..ec656c8319a 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -30,8 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; if (! empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; -$langs->load("admin"); -$langs->load("resource"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","resource")); // Security check if (!$user->admin) @@ -76,7 +76,6 @@ print ''; print ''; print ''; -$var=true; print '
'.$langs->trans("Tag").''.$langs->trans("Description").'
<'.$printer->tags[$tag].'>'.$langs->trans(strtoupper($printer->tags[$tag])).'
'; print ''; print ''."\n"; @@ -85,7 +84,6 @@ print ''; // Utilisation formulaire Ajax sur choix produit - print ''; print ''; if (empty($conf->use_javascript_ajax)) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 38cd2d12c1b..7a216c35423 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -29,9 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $action=GETPOST('action','aZ09'); -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); +// Load traductions files requiredby by page +$langs->loadLangs(array("users","admin","other")); if (!$user->admin) accessforbidden(); @@ -178,10 +177,6 @@ if ($action == 'maj_pattern') - - - - /* * View */ @@ -201,9 +196,6 @@ $head=security_prepare_head(); dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1); -$var=false; - - // Choix du gestionnaire du generateur de mot de passe print ''; print ''; @@ -250,7 +242,6 @@ foreach ($arrayhandler as $key => $module) if ($module->isEnabled()) { - $var = !$var; print ''; + $html .= ''; $html .= ''; $html .= ''; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 90cf8bad1b4..2fa0ee44178 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -1010,7 +1010,7 @@ class Don extends CommonObject $object=$this; $classname = $modele; - $obj = new $classname($db); + $obj = new $classname($this->db); // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. @@ -1028,7 +1028,7 @@ class Don extends CommonObject { $outputlangs->charset_output=$sav_charset_output; dol_syslog("Erreur dans don_create"); - dol_print_error($db,$obj->error); + dol_print_error($this->db,$obj->error); return 0; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b7ee4ee7232..de09e800ede 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -573,9 +573,9 @@ class CommandeFournisseur extends CommonOrder */ function LibStatut($statut,$mode=0,$billed=0) { - if (empty($this->statuts) || empty($statutshort)) + if (empty($this->statuts) || empty($this->statutshort)) { - global $langs; + global $conf, $langs; $langs->load('orders'); $this->statuts[0] = 'StatusOrderDraft'; @@ -591,19 +591,17 @@ class CommandeFournisseur extends CommonOrder $this->statuts[9] = 'StatusOrderRefused'; // List of language codes for status - $statutshort[0] = 'StatusOrderDraftShort'; - $statutshort[1] = 'StatusOrderValidatedShort'; - $statutshort[2] = 'StatusOrderApprovedShort'; - $statutshort[3] = 'StatusOrderOnProcessShort'; - $statutshort[4] = 'StatusOrderReceivedPartiallyShort'; - $statutshort[5] = 'StatusOrderReceivedAllShort'; - $statutshort[6] = 'StatusOrderCanceledShort'; - $statutshort[7] = 'StatusOrderCanceledShort'; - $statutshort[9] = 'StatusOrderRefusedShort'; + $this->statutshort[0] = 'StatusOrderDraftShort'; + $this->statutshort[1] = 'StatusOrderValidatedShort'; + $this->statutshort[2] = 'StatusOrderApprovedShort'; + $this->statutshort[3] = 'StatusOrderOnProcessShort'; + $this->statutshort[4] = 'StatusOrderReceivedPartiallyShort'; + $this->statutshort[5] = 'StatusOrderReceivedAllShort'; + $this->statutshort[6] = 'StatusOrderCanceledShort'; + $this->statutshort[7] = 'StatusOrderCanceledShort'; + $this->statutshort[9] = 'StatusOrderRefusedShort'; } - $langs->load('orders'); - $billedtext=''; //if ($statut==5 && $this->billed == 1) $statut = 8; if ($billed == 1) $billedtext=$langs->trans("Billed"); @@ -614,7 +612,7 @@ class CommandeFournisseur extends CommonOrder } if ($mode == 1) { - return $langs->trans($statutshort[$statut]); + return $langs->trans($this->statutshort[$statut]); } if ($mode == 2) { @@ -644,14 +642,14 @@ class CommandeFournisseur extends CommonOrder } if ($mode == 5) { - if ($statut==0) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); - if ($statut==1) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1'); - if ($statut==2) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==3) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==4) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==5) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); - if ($statut==6 || $statut==7) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); - if ($statut==9) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); + if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1'); + if ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==3) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==4) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==5) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); + if ($statut==6 || $statut==7) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); + if ($statut==9) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d4b1c14b522..6b4c45eafad 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1493,9 +1493,10 @@ class FactureFournisseur extends CommonInvoice */ 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='') { - dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); + global $langs, $mysoc, $conf; + + dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - global $mysoc, $conf; // Clean parameters if (empty($remise_percent)) $remise_percent=0; @@ -1514,7 +1515,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." qty=".$qty." ref_supplier=".$ref_supplier); $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9815d664ae3..a1d6f722994 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -352,7 +352,7 @@ class MyObject extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode=0) + function LibStatut($status, $mode=0) { if (empty($this->labelstatus)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index a39fba04b81..31a89ab332e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -403,7 +403,7 @@ class SupplierProposal extends CommonObject if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { diff --git a/htdocs/ticketsup/class/api_tickets.class.php b/htdocs/ticketsup/class/api_tickets.class.php index d0cd018648c..79fd497ba4f 100644 --- a/htdocs/ticketsup/class/api_tickets.class.php +++ b/htdocs/ticketsup/class/api_tickets.class.php @@ -20,13 +20,12 @@ require 'ticketsup.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php'; + /** * API class for ticketsup object * * @access protected * @class DolibarrApiAccess {@requires user,external} - * - * */ class Tickets extends DolibarrApi { @@ -311,18 +310,14 @@ class Tickets extends DolibarrApi $sql.= $db->order($sortfield, $sortorder); - $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } - } + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit, $offset); + } $result = $db->query($sql); if ($result) { From f773317bf5c7061bf84a6e66a1d83583278e2149 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 May 2018 15:55:42 +0200 Subject: [PATCH 143/183] remove comment and move table --- htdocs/compta/facture/card.php | 377 +++++++++++---------------------- 1 file changed, 124 insertions(+), 253 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index eda10c1773b..60ed4386b66 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3838,180 +3838,10 @@ else if ($id > 0 || ! empty($ref)) print ""; print ''; - // Situations - /*if (! empty($conf->global->INVOICE_USE_SITUATION)) - { - if ($object->type == 5 && ($object->situation_counter > 1)) - { - $prevsits = $object->get_prev_sits(); - print ''; - print ''; - - // Previous situation(s) deduction(s) - for ($i = 0; $i < $cprevsits; $i++) { - print ''; - - print ''; - } - } - }*/ + - // List of previous situation invoices - if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) - { - - print '
'.$langs->trans("Parameters").'
'.$langs->trans("UseSearchToSelectResource").'
'; print ucfirst($key); print "\n"; @@ -395,7 +386,6 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ // Cryptage mot de passe print '
'; -$var=true; print ""; print ''; print ""; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 60d0888ed91..6cea0e6927a 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); +// Load traductions files requiredby by page +$langs->loadLangs(array("users","admin","other")); if (! $user->admin) accessforbidden(); @@ -107,8 +106,6 @@ dol_fiche_head($head, 'misc', $langs->trans("Security"), -1); // Other Options -$var=true; - print ''; print ''; print ''; @@ -116,7 +113,6 @@ print ''; print ''; // Enable Captcha code - print ''; print ''; print ''; // Enable advanced perms - print ''; print ''; print '"; print "\n"; - $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end, $modetax, 'sell'); $action = "tvaclient"; $object = &$coll_list; @@ -248,7 +248,7 @@ if($calc ==0 || $calc == 1){ $company_static=new Societe($db); - $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); + $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end,$modetax, 'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index e6cdf738b96..0eb40cd4d56 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -107,8 +107,12 @@ function pt ($db, $sql, $date) $amountpaid = 0; $previousmonth = ''; $previousmode = ''; + $mode = ''; + while ($i < $num) { $obj = $db->fetch_object($result); + $mode = $obj->mode; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; if ($obj->mode == 'claimed' && ! empty($previousmode)) { @@ -154,7 +158,7 @@ function pt ($db, $sql, $date) $i++; } - if ($obj->mode == 'claimed' && ! empty($previousmode)) + if ($mode == 'claimed' && ! empty($previousmode)) { print ''; print '\n"; @@ -173,6 +177,7 @@ function pt ($db, $sql, $date) print ""; print "
'.$langs->trans("Parameters").''.$langs->trans("Status").'
'.$langs->trans("UseCaptchaCode").''; @@ -146,7 +142,6 @@ else print '
'.$langs->trans("UseAdvancedPerms").''; @@ -174,8 +169,6 @@ print '
'; // Timeout -$var=true; - print ''; print ''; print ''; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 0027f2e834d..9d18d443775 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -25,12 +25,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("sms"); -$langs->load("other"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies","admin","products","sms","other","errors")); if (!$user->admin) accessforbidden(); @@ -169,30 +165,25 @@ if ($action == 'edit') print ''; clearstatcache(); - $var=true; print '
'.$langs->trans("Parameters").'
'; print ''; - // Disable - + // Disable print ''; - // Separator - + // Separator print ''; - // Method - + // Method print ''; - // From - + // From print ''; print ''; @@ -216,31 +207,26 @@ if ($action == 'edit') } else { - $var=true; if (! count($listofmethods)) print '
'.$langs->trans("NoSmsEngine",'DoliStore').'
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_SMS").''; print $form->selectyesno('MAIN_DISABLE_ALL_SMS',$conf->global->MAIN_DISABLE_ALL_SMS,1); print '
 
'.$langs->trans("MAIN_SMS_SENDMODE").''; if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE',$listofmethods,$conf->global->MAIN_SMS_SENDMODE,1); else print ''.$langs->trans("None").''; print '
'.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).'
'; print ''; - // Disable - + // Disable print ''; - // Separator - + // Separator print ''; - // Method - + // Method print ''; - // From - + // From print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print "\n"; @@ -253,9 +257,44 @@ if (! $rowid && $action != 'create' && $action != 'edit') //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''; - print ''; - print ''; - if ($user->rights->asset->configurer) + + print ''; + + print ''; + + print ''; + + if ($user->rights->asset->write) print ''; else print ''; @@ -282,8 +321,9 @@ if (! $rowid && $action != 'create' && $action != 'edit') if ($action == 'create') { $object = new AssetType($db); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); - print load_fiche_titre($langs->trans("NewMemberType")); + print load_fiche_titre($langs->trans("NewAssetType")); print ''; print ''; @@ -296,23 +336,48 @@ if ($action == 'create') print ''; - print ''; + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_asset + print ''; + print ''; - print ''; + // Accountancy_code_depreciation_expense + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + + } + else // For external software + { + // Accountancy_code_asset + print ''; + print ''; + + // Accountancy_code_depreciation_asset + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + } print ''; - print ''; - // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook @@ -356,9 +421,9 @@ if ($rowid > 0) print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1); } - $head = member_type_prepare_head($object); + $head = asset_type_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); + dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); $linkback = ''.$langs->trans("BackToList").''; @@ -369,20 +434,45 @@ if ($rowid > 0) print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_SMS").''.yn($conf->global->MAIN_DISABLE_ALL_SMS).'
 
'.$langs->trans("MAIN_SMS_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE]; if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning(); print $text; print '
'.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMS_FROM; if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); From 9c6f92986e63d7040ec395f40305f9a5b6e0e5b5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 11 May 2018 21:48:22 +0200 Subject: [PATCH 116/183] Upgrade works --- htdocs/asset/class/asset_type.class.php | 19 ++ htdocs/asset/type.php | 227 ++++++++++++++++-------- htdocs/core/lib/asset.lib.php | 29 +++ htdocs/core/menus/standard/eldy.lib.php | 10 +- htdocs/langs/en_US/assets.lang | 11 +- 5 files changed, 217 insertions(+), 79 deletions(-) diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 9fbcca64d8b..51ea3a0c799 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -73,14 +73,23 @@ class AssetType extends CommonObject $error=0; $this->label=trim($this->label); + $this->accountancy_code_asset = trim($this->accountancy_code_asset); + $this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset); + $this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; $sql.= "label"; + $sql.= ", accountancy_code_asset"; + $sql.= ", accountancy_code_depreciation_asset"; + $sql.= ", accountancy_code_depreciation_expense"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -411,4 +420,14 @@ class AssetType extends CommonObject ); } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + function getLibStatut() + { + return ''; + } + } diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index d26175d168f..64800488cb6 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -26,6 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $langs->load("assets"); @@ -232,8 +235,9 @@ if (! $rowid && $action != 'create' && $action != 'edit') print '
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("SubscriptionRequired").''.$langs->trans("VoteAllowed").''.$langs->trans("AccountancyCodeAsset").''.$langs->trans("AccountancyCodeDepreciationAsset").''.$langs->trans("AccountancyCodeDepreciationExpense").' 
'.dol_escape_htmltag($objp->label).''.yn($objp->subscription).''.yn($objp->vote).''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code_asset,1); + + print $accountingaccount->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); + + print $accountingaccount2->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); + + print $accountingaccount3->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_expense; + } + print 'rowid.'">'.img_edit().' 
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; - print $form->selectyesno("subscription",1,1); - print '
'.$langs->trans("AccountancyCodeAsset").''; + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); + print '
'.$langs->trans("VoteAllowed").''; - print $form->selectyesno("vote",0,1); - print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print '
'.$langs->trans("Description").''; print '
'.$langs->trans("WelcomeEMail").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); - $doleditor->Create(); - print '
'; - print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code_asset,1); - print ''; + + print ''; + + print ''; print '"; - print '"; - // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -612,35 +702,6 @@ if ($rowid > 0) print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); print ""; - // Date end subscription - if ($datefin) - { - print ''; - } - else - { - print ''; - } - // Actions print '\n"; print " \n"; print ''."\n"; - $var = !$var; + print ''; print ''; print '\n"; print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -403,7 +400,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; print ''; print ''; print "\n"; -$var=true; print ''; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -202,7 +201,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print '\n"; - // Array Data - $var=true; - if (count($name)) { foreach($name as $key=>$value) { print ''; // Product + print "\n"; + print $linkname; + print "\n"; // Quantity print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $db->free($result); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index ed36d677df9..5c1e8cc4db7 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -90,8 +90,8 @@ $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GE // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int")?GETPOST("q","int"):0; + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index ea2d6fa9c03..bb5cb25e30d 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -565,7 +565,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -614,7 +614,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -622,7 +622,7 @@ print ''; { dol_print_error($db); } - print ""; + print ""; } print "
'.$langs->trans("SubscriptionRequired").''; - print yn($object->subscription); print '
'.$langs->trans("VoteAllowed").''; - print yn($object->vote); + print $accountingaccount->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); + + print $accountingaccount2->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); + + print $accountingaccount3->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_expense; + } print '
'.$langs->trans("Description").''; print nl2br($object->note)."
'.$langs->trans("WelcomeEMail").''; - print nl2br($object->mail_valid)."
'; - if ($datefin < dol_now() && $objp->statut > 0) - { - print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); - } - else - { - print dol_print_date($datefin,'day'); - } - print ''; - if ($objp->subscription == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; if ($user->rights->asset->creer) @@ -685,15 +746,16 @@ if ($rowid > 0) $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); - $head = member_type_prepare_head($object); + $head = asset_type_prepare_head($object); print ''; print ''; print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); + dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); print ''; @@ -701,23 +763,48 @@ if ($rowid > 0) print ''; - print ''; + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_asset + print ''; + print ''; - print ''; + // Accountancy_code_depreciation_expense + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + + } + else // For external software + { + // Accountancy_code_asset + print ''; + print ''; + + // Accountancy_code_depreciation_asset + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + } print ''; - print '"; - // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 460d368f2c4..5953c8b9420 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -118,3 +118,32 @@ function AssetsPrepareHead() return $head; } + +/** + * Return array head with list of tabs to view object informations + * + * @param AssetType $object Asset + * @return array head + */ +function asset_type_prepare_head(AssetType $object) +{ + global $langs, $conf, $user; + + $h=0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove'); + + return $head; +} diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4d3951f7b5e..69db8554729 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1143,11 +1143,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("assets"); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); - $newmenu->add("/asset/card.php?leftmenu=asset&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); - $newmenu->add("/asset/type.php?leftmenu=asset",$langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); - $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create",$langs->trans("MenuNewTypeAssets"), 1, $user->rights->asset->write); - $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuListTypeAssets"), 1, $user->rights->asset->read); - $newmenu->add("/asset/list.php?leftmenu=asset",$langs->trans("MenuListAssets"), 1, $user->rights->asset->read); + $newmenu->add("/asset/card.php?action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); + $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy",$langs->trans("MenuListAssets"), 1, $user->rights->asset->read); + $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); + if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/',$leftmenu)) $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create",$langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write); + if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/',$leftmenu)) $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read); } } diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index cd310e48333..db865ff3f87 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -18,9 +18,10 @@ # Assets = Assets NewAsset = New asset -AccountancyAccountAsset = Accounting code (asset) -AccountancyAccountDepreciationAsset = Accounting code (depreciation asset account) -AccountancyAccountDepreciationExpense = Accounting code (depreciation expense account) +AccountancyCodeAsset = Accounting code (asset) +AccountancyCodeDepreciationAsset = Accounting code (depreciation asset account) +AccountancyCodeDepreciationExpense = Accounting code (depreciation expense account) +NewAssetType=New asset type # Module label 'ModuleAssetsName' ModuleAssetsName = Assets @@ -44,5 +45,7 @@ AssetsTypes=Assets types # MenuAssets = Assets MenuNewAsset = New asset -MenuTypeAssets = Type +MenuTypeAssets = Type assets MenuListAssets = List +MenuNewTypeAssets = New type +MenuListTypeAssets = List From edbe32ea0c622a2ae0fe2e7ebb5c1c48472ce8c2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 11 May 2018 22:31:17 +0200 Subject: [PATCH 117/183] clean and update code --- htdocs/admin/spip.php | 7 ++----- htdocs/admin/stock.php | 25 ++++++++++--------------- htdocs/admin/supplier_invoice.php | 8 +++----- htdocs/admin/supplier_order.php | 8 +++----- htdocs/admin/supplier_payment.php | 11 ++--------- htdocs/admin/supplier_proposal.php | 14 ++++---------- htdocs/admin/syslog.php | 1 - htdocs/admin/usergroup.php | 8 +++----- 8 files changed, 27 insertions(+), 55 deletions(-) diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index 1452ea572d0..850625859b6 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -32,9 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("admin"); -$langs->load("members"); -$langs->load("mailmanspip"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "members", "mailmanspip")); if (! $user->admin) accessforbidden(); @@ -118,8 +117,6 @@ print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup' $head = mailmanspip_admin_prepare_head(); -$var=true; - /* * Spip */ diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e7c77f5955f..2e6cd133942 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -3,7 +3,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012-2013 Juanjo Menent - * Copyright (C) 2013-2017 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -28,8 +28,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -$langs->load("admin"); -$langs->load("stocks"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "stocks")); // Securit check if (!$user->admin) accessforbidden(); @@ -162,11 +162,9 @@ print ''; print " \n"; print " \n"; print ''."\n"; -$var=true; $found=0; - print ''; print ''; print ''; print " \n"; print " \n"; print ''."\n"; -$var=true; $found=0; - print ''; print ''; print '\n"; print "\n"; // Option to force stock to be enough before adding a line into document -if($conf->invoice->enabled) { - $var = !$var; +if($conf->invoice->enabled) +{ print ''; print ''; print '\n"; } -if($conf->order->enabled) { - $var = !$var; +if($conf->order->enabled) +{ print ''; print ''; print '\n"; } -if($conf->expedition->enabled) { - $var = !$var; +if($conf->expedition->enabled) +{ print ''; print ''; print '
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; - print $form->selectyesno("subscription",$object->subscription,1); - print '
'.$langs->trans("AccountancyCodeAsset").''; + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); + print '
'.$langs->trans("VoteAllowed").''; - print $form->selectyesno("vote",$object->vote,1); - print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print '
'.$langs->trans("Description").''; print '
'.$langs->trans("WelcomeEMail").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); - $doleditor->Create(); - print "
".$langs->trans("RuleForStockManagementDecrease")." 
'.$langs->trans("DeStockOnBill").''; @@ -266,11 +264,9 @@ print '
".$langs->trans("RuleForStockManagementIncrease")." 
'.$langs->trans("ReStockOnBill").''; @@ -362,8 +358,8 @@ print "
'.$langs->trans("StockMustBeEnoughForInvoice").''; @@ -377,8 +373,8 @@ if($conf->invoice->enabled) { print "
'.$langs->trans("StockMustBeEnoughForOrder").''; @@ -392,8 +388,8 @@ if($conf->order->enabled) { print "
'.$langs->trans("StockMustBeEnoughForShipment").''; @@ -408,7 +404,6 @@ if($conf->expedition->enabled) { } print '
'; - print '
'; $virtualdiffersfromphysical=0; @@ -423,7 +418,7 @@ if ($virtualdiffersfromphysical) print "
".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))." 
'.$langs->trans("UseVirtualStockByDefault").''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 1532ca0a89d..485e8fc06b2 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -34,9 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->load("admin"); -$langs->load("other"); -$langs->load("orders"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "orders")); if (!$user->admin) accessforbidden(); @@ -233,7 +232,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index b86b674e9ad..dd0b136ef4f 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -34,9 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -$langs->load("admin"); -$langs->load("other"); -$langs->load("orders"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "orders")); if (!$user->admin) accessforbidden(); @@ -262,7 +261,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 86cd8d02207..81ac029e244 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -27,12 +27,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('bills'); -$langs->load('orders'); - +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "errors", "other", "bills", "orders")); if (! $user->admin) accessforbidden(); @@ -217,7 +213,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -249,7 +244,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - $var = !$var; print '
'; echo preg_replace('/\-.*$/','',preg_replace('/mod_supplier_payment_/','',preg_replace('/\.php$/','',$file))); print "\n"; @@ -360,7 +354,6 @@ foreach ($dirmodels as $reldir) require_once $dir.'/'.$file; $module = new $classname($db, new PaiementFourn($db)); - print "
"; print (empty($module->name)?$name:$module->name); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 0c389f6b4c2..6c9e01b621b 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -28,10 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('supplier_proposal'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "errors", "other", "supplier_proposal")); if (! $user->admin) accessforbidden(); @@ -247,7 +246,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -366,7 +364,6 @@ print "
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -492,7 +488,6 @@ print '
'; */ print load_fiche_titre($langs->trans("OtherOptions"),'',''); -$var=true; print ""; print ""; print "\n"; @@ -506,7 +501,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; @@ -585,7 +579,7 @@ print "\n"; print " \n"; print " \n"; print "\n"; -print "\n \n \n\n"; +print "\n \n \n\n"; print "
".$langs->trans("Parameter")."
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("PathDirectory")."".$conf->supplier_proposal->dir_output."
".$langs->trans("PathDirectory")."".$conf->supplier_proposal->dir_output."
\n
"; llxFooter(); diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index bd2e07ef97d..10299015b8b 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -279,7 +279,6 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("SyslogLevel").'
'; print (empty($module->name)?$name:$module->name); print "\n"; From 29c735d8bd1fc8125f40eec6f4330091e0136e5e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 12 May 2018 10:46:17 +0200 Subject: [PATCH 118/183] Clean and update code --- htdocs/bookmarks/admin/bookmark.php | 2 -- htdocs/cashdesk/admin/cashdesk.php | 7 ++----- htdocs/categories/admin/categorie.php | 1 - htdocs/categories/index.php | 3 +-- htdocs/comm/action/card.php | 9 ++------- htdocs/comm/action/rapport/index.php | 5 ++--- 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 9b3bea82af1..709fadc6301 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -68,8 +68,6 @@ print ''; print ''; print ''; -$var=true; - print ''; print ''; print ''; diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 5a68b37caac..8d3d62e169a 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -38,8 +38,8 @@ if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("cashdesk"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "cashdesk")); /* @@ -91,7 +91,6 @@ print '
'; // Mode -$var=true; print ''; print ''; print ''; @@ -162,7 +161,6 @@ if (! empty($conf->stock->enabled)) if (! empty($conf->service->enabled)) { - $var=! $var; print ''; print ''."\n"; print ''; -$var=true; $form = new Form($db); // Mail required for members diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 149eb160a78..88dea3ea761 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -82,7 +82,7 @@ print '
'.$langs->trans("Name").'
'; print $langs->trans("CashdeskShowServices"); print ''; @@ -173,7 +171,6 @@ if (! empty($conf->service->enabled)) // Use Dolibarr Receipt Printer if (! empty($conf->receiptprinter->enabled)) { - $var=! $var; print '
'; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; print ''; diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index 518d8903edd..e0c51803faf 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -93,7 +93,6 @@ print ' '.$langs->trans("Value").'
'; print ''; print ''; print ''; -print ''; /* // faire une rech dans une sous categorie uniquement @@ -111,7 +111,6 @@ if ($catname || $id > 0) print '
'.$langs->trans("Search").'
'; +print '
'; print $langs->trans("Name").':
'; print ''; - $var=true; foreach ($cats as $cat) { print "\t".''."\n"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fb9c5944baf..7832c922ef0 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -42,12 +42,8 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("companies"); -$langs->load("commercial"); -$langs->load("other"); -$langs->load("bills"); -$langs->load("orders"); -$langs->load("agenda"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda")); $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel','alpha'); @@ -1603,7 +1599,6 @@ if ($id > 0) $genallowed=$user->rights->agenda->myactions->read; $delallowed=$user->rights->agenda->myactions->create; - $var=true; print $formfile->showdocuments('agenda',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 93cbae527f1..268018d02e4 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php'; -$langs->load("agenda"); -$langs->load("commercial"); +// Load traductions files requiredby by page +$langs->loadLangs(array("agenda", "commercial")); $action=GETPOST('action','alpha'); $month=GETPOST('month'); @@ -138,7 +138,6 @@ if ($resql) print ''; print "\n"; - $var=true; while ($i < min($num,$limit)) { $obj=$db->fetch_object($resql); From 94ccb44673c6485c7695ef11caf8817a903a73d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:02:44 +0200 Subject: [PATCH 119/183] Fix bad url wor external subscription page --- htdocs/adherents/admin/website.php | 8 +++++++- htdocs/admin/agenda_xcal.php | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 0a560c402fd..b35df5f0083 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -241,7 +241,13 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) } else { $entity_qr=''; } - print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.''; + + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + print ''.$urlwithroot.'/public/members/new.php'.$entity_qr.''; } diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index ac19eb24c03..ab0effc2c45 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -32,9 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("other"); -$langs->load("agenda"); +$langs->loadLangs(array("admin","other","agenda")); $def = array(); $actionsave=GETPOST('save','alpha'); From 63ed5dcccce62c78100b9a566bad25772b8e2c10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:23:40 +0200 Subject: [PATCH 120/183] Fix securekey for new online payment form --- htdocs/comm/mailing/card.php | 2 +- htdocs/public/members/new.php | 37 ++++++++++++++------------- htdocs/public/members/public_card.php | 5 ++-- htdocs/public/members/public_list.php | 5 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 5ded0c16b5e..bb68f85ea16 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -244,7 +244,7 @@ if (empty($reshook)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); } } - /* For backward compatibility */ + /* For backward compatibility, deprecated */ if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b6d87ce9ac2..b92e84b8352 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -35,8 +35,9 @@ * MEMBER_NEWFORM_FORCECOUNTRYCODE Force country */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -356,7 +357,7 @@ if ($action == 'add') if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { $urlback=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -373,51 +374,51 @@ if ($action == 'add') else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->PAYBOX_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->PAYBOX_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYBOX_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->PAYBOX_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->PAYPAL_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { $urlback=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->STRIPE_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->STRIPE_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->STRIPE_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index f3027eb0149..5dee0eb49a3 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -24,8 +24,9 @@ * \brief File to show a public card of a member */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index b3438e8be02..1f9a4406028 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -24,8 +24,9 @@ * \brief File sample to list members */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php From b84baece3c980e5a0008f24c851eb715b38ff476 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:32:00 +0200 Subject: [PATCH 121/183] Code comment --- htdocs/modulebuilder/template/myobject_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 5b2a1213c0f..48a039e4edf 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -31,11 +31,11 @@ //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message From 53b5733fb4a515f97ded7c7d5267856e2290cc83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 13:40:53 +0200 Subject: [PATCH 122/183] Fix test --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/public/test/test_forms.php | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fa606639bcc..9cba6ed839e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4775,7 +4775,7 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0). + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty @@ -4813,7 +4813,7 @@ class Form } // Analysis of the pre-selection date - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) // deprecated usage { // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' $syear = (! empty($reg[1])?$reg[1]:''); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index a53f812611a..0250bb2c39f 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -28,11 +28,16 @@ This page is a sample of page using Dolibarr HTML widget methods. It is designed $form=new Form($db); // Test1: form->select_date using tzuser date -print "Test 1: We must have here current hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; +print "Test 1a: We must have here current date and hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")
\n"; -$form->select_date('', 'test1', 1, 1, 0); +$form->select_date(dol_now(), 'test1a', 1, 1, 0); + +print '

'."\n"; + +print "Test 1b: We must have here current date with hours to 00:00.
"; +$form->select_date('', 'test1b', 1, 1, 0); print '

'."\n"; From cb815e5e3b9f23a9d01106cb5953eaf08a5382d2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 May 2018 07:50:24 +0200 Subject: [PATCH 123/183] Update works --- htdocs/asset/class/asset.class.php | 5 +- htdocs/asset/type.php | 13 ++-- htdocs/core/modules/modAsset.class.php | 64 +++++++++++++++---- .../install/mysql/migration/7.0.0-8.0.0.sql | 5 +- htdocs/install/mysql/tables/llx_asset.key.sql | 1 - htdocs/install/mysql/tables/llx_asset.sql | 4 +- htdocs/langs/en_US/assets.lang | 1 + 7 files changed, 67 insertions(+), 26 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 86da8ae5379..bf392b52310 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -78,8 +78,9 @@ class Asset extends CommonObject 'ref' => array('type'=>'varchar(10)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",), - 'amount' => array('type'=>'double(24,8)', 'label'=>'Amount', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), + 'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), + 'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), + 'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,), diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 64800488cb6..1b909108b66 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -488,7 +488,7 @@ if ($rowid > 0) print '
'; // Edit - if ($user->rights->asset->configurer) + if ($user->rights->asset->write) { print ''; } @@ -497,7 +497,7 @@ if ($rowid > 0) print ''; // Delete - if ($user->rights->asset->configurer) + if ($user->rights->asset->write) { print ''; } @@ -505,8 +505,7 @@ if ($rowid > 0) print "
"; - // Show list of members (nearly same code than in page list.php) - + // Show list of assets (nearly same code than in page list.php) $assettypestatic=new AssetType($db); $now=dol_now(); @@ -516,7 +515,7 @@ if ($rowid > 0) $sql.= " a.fk_asset_type as type_id,"; $sql.= " t.label as type"; $sql.= " FROM ".MAIN_DB_PREFIX."asset as a, ".MAIN_DB_PREFIX."asset_type as t"; - $sql.= " WHERE a.fk_asset_type = t.rowid "; + $sql.= " WHERE a.fk_asset_type = t.rowid"; $sql.= " AND a.entity IN (".getEntity('asset').")"; $sql.= " AND t.rowid = ".$object->id; if ($sall) @@ -531,8 +530,8 @@ if ($rowid > 0) { if (GETPOST('search','alpha')) { - $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha')); - } + $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha')); + } } if (! empty($search_lastname)) { diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 6b7985a0e23..0f8f3c816b4 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -219,23 +219,65 @@ class modAsset extends DolibarrModules $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports + //-------- $r=1; + // $this->export_code[$r] Code unique identifiant l'export (tous modules confondus) + // $this->export_label[$r] Libelle par defaut si traduction de cle "ExportXXX" non trouvee (XXX = Code) + // $this->export_permission[$r] Liste des codes permissions requis pour faire l'export + // $this->export_fields_sql[$r] Liste des champs exportables en codif sql + // $this->export_fields_name[$r] Liste des champs exportables en codif traduction + // $this->export_sql[$r] Requete sql qui offre les donnees a l'export + /* - $langs->load("fixedassets@fixedassets"); + $r++; $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='FixedAssetsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='fixedassets@fixedassets'; - $keyforclass = 'FixedAssets'; $keyforclassfile='/mymobule/class/fixedassets.class.php'; $keyforelement='fixedassets'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='fixedassets'; $keyforaliasextra='extra'; $keyforelement='fixedassets'; + $this->export_label[$r]='AssetsLines'; + $this->export_permission[$r]=array(array("asset","export")); + $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'AssetTypeId','ta.label'=>'AssetTypeLabel','ta.accountancy_code_asset'=>'AccountancyCodeAsset','ta.accountancy_code_depreciation_asset'=>'AccountancyCodeDepreciationAsset','ta.accountancy_code_depreciation_expense'=>'AccountancyCodeDepreciationExpense'); + $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:asset_type:label','ta.label'=>'Text','ta.accountancy_code_asset'=>'Text','ta.accountancy_code_depreciation_asset'=>'Text','ta.accountancy_code_depreciation_expense'=>'Text'); + $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'asset_type','ta.label'=>'asset_type''ta.accountancy_code_asset'=>'asset_type''ta.accountancy_code_depreciation_asset'=>'asset_type''ta.accountancy_code_depreciation_expense'=>'asset_type'); + // Add extra fields + $keyforselect='asset'; $keyforelement='asset'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fixedassets as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('fixedassets').')'; - $r++; */ + $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'asset_type as ta, '.MAIN_DB_PREFIX.'asset as a)'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'asset_extrafields as extra ON a.rowid = extra.fk_object'; + $this->export_sql_end[$r] .=' WHERE a.fk_asset_type = ta.rowid AND ta.entity IN ('.getEntity('asset_type').') '; + + // Imports + //-------- + $r=0; + + $now=dol_now(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="Assets"; // Translation key + $this->import_icon[$r]=$this->picto; + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'asset','extra'=>MAIN_DB_PREFIX.'asset_extrafields'); + $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r]=array('a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'asset' AND entity = ".$conf->entity; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'asset'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r]=array('a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + $this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); + */ } /** diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index a57e02455cc..bf5f0400b9a 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -389,9 +389,9 @@ CREATE TABLE llx_asset( ref varchar(128) NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), - amount double(24,8) DEFAULT NULL, + amount_ht double(24,8) DEFAULT NULL, + amount_vat double(24,8) DEFAULT NULL, fk_asset_type integer NOT NULL, - fk_soc integer, description text, note_public text, note_private text, @@ -406,7 +406,6 @@ CREATE TABLE llx_asset( ALTER TABLE llx_asset ADD INDEX idx_asset_rowid (rowid); ALTER TABLE llx_asset ADD INDEX idx_asset_ref (ref); ALTER TABLE llx_asset ADD INDEX idx_asset_entity (entity); -ALTER TABLE llx_asset ADD INDEX idx_asset_fk_soc (fk_soc); ALTER TABLE llx_asset ADD INDEX idx_asset_fk_asset_type (fk_asset_type); diff --git a/htdocs/install/mysql/tables/llx_asset.key.sql b/htdocs/install/mysql/tables/llx_asset.key.sql index 6befef7455f..31bed33a3ee 100644 --- a/htdocs/install/mysql/tables/llx_asset.key.sql +++ b/htdocs/install/mysql/tables/llx_asset.key.sql @@ -17,7 +17,6 @@ ALTER TABLE llx_asset ADD INDEX idx_asset_rowid (rowid); ALTER TABLE llx_asset ADD INDEX idx_asset_ref (ref); ALTER TABLE llx_asset ADD INDEX idx_asset_entity (entity); -ALTER TABLE llx_asset ADD INDEX idx_asset_fk_soc (fk_soc); ALTER TABLE llx_asset ADD INDEX idx_asset_fk_asset_type (fk_asset_type); ALTER TABLE llx_asset ADD CONSTRAINT fk_asset_asset_type FOREIGN KEY (fk_asset_type) REFERENCES llx_asset_type (rowid); diff --git a/htdocs/install/mysql/tables/llx_asset.sql b/htdocs/install/mysql/tables/llx_asset.sql index a583bd9275e..d6eba5ed93b 100644 --- a/htdocs/install/mysql/tables/llx_asset.sql +++ b/htdocs/install/mysql/tables/llx_asset.sql @@ -19,9 +19,9 @@ CREATE TABLE llx_asset( ref varchar(128) NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), - amount double(24,8) DEFAULT NULL, + amount_ht double(24,8) DEFAULT NULL, + amount_vat double(24,8) DEFAULT NULL, fk_asset_type integer NOT NULL, - fk_soc integer, description text, note_public text, note_private text, diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index db865ff3f87..0f955fe19ce 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -22,6 +22,7 @@ AccountancyCodeAsset = Accounting code (asset) AccountancyCodeDepreciationAsset = Accounting code (depreciation asset account) AccountancyCodeDepreciationExpense = Accounting code (depreciation expense account) NewAssetType=New asset type +AssetsLines=Assets # Module label 'ModuleAssetsName' ModuleAssetsName = Assets From 302d9399e2475fe270a122210b6f5cc7bab529bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 12:42:16 +0200 Subject: [PATCH 124/183] Fix search when using special char --- htdocs/core/class/html.form.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9cba6ed839e..642fe099593 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5542,7 +5542,7 @@ class Form /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select come from an Ajax call of an URL. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5557,7 +5557,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5618,7 +5618,7 @@ class Form /* Code to execute a GET when we select a value */ $(".'.$htmlname.'").change(function() { var selected = $(".'.$htmlname.'").val(); - console.log("We select "+selected) + console.log("We select in selectArrayAjax the entry "+selected) $(".'.$htmlname.'").val(""); /* reset visible combo value */ $.each( saveRemoteData, function( key, value ) { if (key == selected) @@ -5644,7 +5644,7 @@ class Form } /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5659,7 +5659,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ static function selectArrayFilter($htmlname, $array, $id='', $moreparam='', $disableFiltering=0, $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5708,8 +5708,9 @@ class Form var urlBase = data.url; var separ = urlBase.indexOf("?") >= 0 ? "&" : "?"; - - saveRemoteData[data.id].url = urlBase + separ + "sall=" + params.term;'; + /* console.log("params.term="+params.term); */ + /* console.log("params.term encoded="+encodeURIComponent(params.term)); */ + saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term);'; } if(! $disableFiltering) { From c76e866f41bc605ddc7009379f4cd8f5864d541e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:06:57 +0200 Subject: [PATCH 125/183] CSS --- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index ecdda360309..1b0a5303bec 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -91,7 +91,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel if (! empty($conf->multicompany->enabled)) { print '
'; } - print '\n"; print ""; } From a2d485c14fcb4510458d05ffe9cb0795d1604454 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:27:40 +0200 Subject: [PATCH 126/183] Fix management of enabled property extrafields --- htdocs/core/class/extrafields.class.php | 24 ++++++++++++++++++------ htdocs/core/tpl/extrafields_view.tpl.php | 6 +++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 153efd5b8c9..62fd4335315 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,38 +39,50 @@ class ExtraFields var $db; // type of element (for what object is the extrafield) + // @deprecated var $attribute_elementtype; - // Array with type of the extra field + // @deprecated var $attribute_type; // Array with label of extra field + // @deprecated var $attribute_label; // Array with size of extra field + // @deprecated var $attribute_size; // array with list of possible values for some types of extra fields + // @deprecated var $attribute_choice; // Array to store compute formula for computed fields + // @deprecated var $attribute_computed; // Array to store default value + // @deprecated var $attribute_default; // Array to store if attribute is unique or not + // @deprecated var $attribute_unique; // Array to store if attribute is required or not + // @deprecated var $attribute_required; // Array to store parameters of attribute (used in select type) + // @deprecated var $attribute_param; // Array to store position of attribute + // @deprecated var $attribute_pos; // Array to store if attribute is editable regardless of the document status + // @deprecated var $attribute_alwayseditable; // Array to store permission to check + // @deprecated var $attribute_perms; // Array to store language file to translate label of values + // @deprecated var $attribute_langfile; // Array to store if field is visible by default on list + // @deprecated var $attribute_list; - // Array to store if extra field is hidden - var $attribute_hidden; // warning, do not rely on this. If your module need a hidden data, it must use its own table. // New array to store extrafields definition var $attributes; @@ -126,7 +138,6 @@ class ExtraFields $this->attribute_perms = array(); $this->attribute_langfile = array(); $this->attribute_list = array(); - $this->attribute_hidden = array(); } /** @@ -758,7 +769,7 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity"; + $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 @@ -812,6 +823,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); + $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; $this->attributes[$tab->elementtype]['loaded']=1; } @@ -884,7 +896,7 @@ class ExtraFields $param=$this->attribute_param[$key]; $langfile=$this->attribute_langfile[$key]; $list=$this->attribute_list[$key]; - $hidden=$this->attribute_hidden[$key]; + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } if ($computed) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0e3d742e986..06396cf4fb7 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -45,13 +45,17 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -//var_dump($extrafields->attributes); +//var_dump($extrafields->attributes[$object->table_element]); if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Discard if extrafield is a hidden field on form $enabled = 1; + if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$key])) + { + $enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1); + } if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$key])) { $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1); From 0c40dfa3f9b3795450a2a069d016d54edc1a72d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:30:48 +0200 Subject: [PATCH 127/183] Translation --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index a8f9f815cb6..abf262ec9ba 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -156,7 +156,7 @@ BuyingPrices=Buying prices CustomerPrices=Customer prices SuppliersPrices=Supplier prices SuppliersPricesOfProductsOrServices=Supplier prices (of products or services) -CustomCode=Customs/Commodity/HS code +CustomCode=Customs / Commodity / HS code CountryOrigin=Origin country Nature=Nature ShortLabel=Short label From 9b2f62791b2c3bcb8a735b2cde39e4b381e97b6a Mon Sep 17 00:00:00 2001 From: Chl Date: Sun, 13 May 2018 15:43:17 +0200 Subject: [PATCH 128/183] Fix #8722 useless sql ORDER BY --- htdocs/compta/facture/card.php | 1 - htdocs/fourn/facture/card.php | 1 - 2 files changed, 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dbce9c2e76d..42220a74f34 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -720,7 +720,6 @@ if (empty($reshook)) $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND pf.fk_paiement = p.rowid'; $sql.= ' AND p.entity IN (' . getEntity('facture').')'; - $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); if (! $resql) dol_print_error($db); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5cb8e42681e..6da520a14bd 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -508,7 +508,6 @@ if (empty($reshook)) $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' AND pf.fk_paiementfourn = p.rowid'; $sql.= ' AND p.entity IN (' . getEntity('facture').')'; - $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); if (! $resql) dol_print_error($db); From 2f1ac6fad87b6c1dc47f8aba3136772ae976a59c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 May 2018 20:35:07 +0200 Subject: [PATCH 129/183] Fix : Double WHERE on admin/journal_list.php --- htdocs/accountancy/admin/journals_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 37c166dabe9..d65f7eeba7d 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -86,7 +86,7 @@ $tablib[35]= "DictionaryAccountancyJournal"; // Requests to extract data $tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a WHERE a.entity=".$conf->entity; +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; // Criteria to sort dictionaries $tabsqlsort=array(); From 675ae97f997b2c161b12d7e6811f10e98ee149dc Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 May 2018 21:52:11 +0200 Subject: [PATCH 130/183] Update module assets (Add asset directory & langs) --- .tx/config | 6 ++++++ build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + 5 files changed, 10 insertions(+) diff --git a/.tx/config b/.tx/config index a5cbac0997f..6adb0d31a7f 100644 --- a/.tx/config +++ b/.tx/config @@ -20,6 +20,12 @@ source_file = htdocs/langs/en_US/agenda.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.assets] +file_filter = htdocs/langs//assets.lang +source_file = htdocs/langs/en_US/assets.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.banks] file_filter = htdocs/langs//banks.lang source_file = htdocs/langs/en_US/banks.lang diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index df00a982f29..65da8cabfd7 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -160,6 +160,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/api +%_datadir/dolibarr/htdocs/asset %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/blockedlog diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 908a7335415..2fed89c03f3 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -240,6 +240,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/api +%_datadir/dolibarr/htdocs/asset %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/blockedlog diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 4a07c838b78..fb15a2d2d92 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -157,6 +157,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/api +%_datadir/dolibarr/htdocs/asset %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/blockedlog diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 6f1632a57e3..70eba841bd8 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -168,6 +168,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/api +%_datadir/dolibarr/htdocs/asset %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/blockedlog From b42c87256c5b716dfbd3efed4b74d983159de597 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 14 May 2018 14:55:33 +0200 Subject: [PATCH 131/183] Fix_situation_discount_used --- htdocs/compta/facture/card.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f31b0be6a38..e3e7dc3665f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1362,11 +1362,26 @@ if (empty($reshook)) $object->origin = $origin; $object->origin_id = $originid; - foreach ($object->lines as &$line) + foreach ($object->lines as $i => &$line) { $line->origin = $object->origin; $line->origin_id = $line->id; $line->fetch_optionals($line->id); + + // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée + if ($line->fk_remise_except) + { + $discount=new DiscountAbsolute($line->db); + $result=$discount->fetch($line->fk_remise_except); + if ($result > 0) + { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) + { + unset($object->lines[$i]); + } + } + } } } From ca09fddfb32aa5e583b33277ad4acd7462119cd0 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 14 May 2018 15:16:07 +0200 Subject: [PATCH 132/183] FIX : Select user on add time spent form --- htdocs/projet/tasks/time.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 79ff8f9d9b0..2da534e53a0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -568,7 +568,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $contactsoftask=$object->getListContactId('internal'); if (count($contactsoftask)>0) { - $userid=$contactsoftask[0]; + if(in_array($user->id, $contactsoftask)) $userid = $user->id; + else $userid=$contactsoftask[0]; print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsoftask, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToTheTask"), 'maxwidth200'); } else From 9552a914d82d233dc928841a5e02c305adf7af8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 May 2018 15:16:19 +0200 Subject: [PATCH 133/183] FIX link for projets not linked to a thirdparties --- htdocs/projet/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c922ca0514b..1ff9e22041d 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -290,7 +290,10 @@ if ( $resql ) print $langs->trans("OthersNotLinkedToThirdParty"); } print ''; - print ''; + print ''; print "\n"; $i++; From a46362a71f9709400f90a676e4b800de15ea42b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 May 2018 15:17:10 +0200 Subject: [PATCH 134/183] Prepare 7.0.3 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 99a6b550f45..b8126b4fcc8 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','7.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','7.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 88bc2dd41629710baa007f6852d2e89d6be3d237 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 14 May 2018 20:59:38 +0200 Subject: [PATCH 135/183] Correct insert --- htdocs/accountancy/admin/journals_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index d65f7eeba7d..971fdc20811 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -102,7 +102,7 @@ $tabfieldvalue[35]= "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature,entity"; +$tabfieldinsert[35]= "code,label,nature"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on From f342c5c6b3231383f45bdca117ed179afaa74df1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 11:36:39 +0200 Subject: [PATCH 136/183] Page title first --- htdocs/website/index.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f141c6cf417..3a92029e205 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -542,10 +542,10 @@ if ($action == 'addcontainer') } else { + $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER','alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT','alpha'); - $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG','aZ09'); @@ -958,10 +958,10 @@ if ($action == 'updatemeta') { $objectpage->old_object = clone $objectpage; + $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); - $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); @@ -2026,14 +2026,22 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pagelang=$objectpage->lang; $pagehtmlheader=$objectpage->htmlheader; } + if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_PAGENAME','alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME','alpha'); if (GETPOST('WEBSITE_ALIASALT','alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT','alpha'); - if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_DESCRIPTION','alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION','alpha'); if (GETPOST('WEBSITE_KEYWORDS','alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS','alpha'); if (GETPOST('WEBSITE_LANG','aZ09')) $pagelang=GETPOST('WEBSITE_LANG','aZ09'); if (GETPOST('htmlheader','none')) $pagehtmlheader=GETPOST('htmlheader','none'); + // Title + print ''; + + // Alias print ''; } - print ''; - print ''; + // GDPR contact + + print ''; + // Capital print ''; + // GDPR Contact + + print ''; + // Capital print ''; - print '\n"; + print '\n"; print '\n"; print '\n"; print "\n"; @@ -129,7 +130,7 @@ function pt ($db, $sql, $date) if ($obj->mode == 'paid') { $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaied; + $totalpaid = $totalpaid + $amountpaid; } if ($obj->mode == 'paid') @@ -142,10 +143,12 @@ function pt ($db, $sql, $date) $amountclaimed = 0; $amountpaid = 0; $previousmode = ''; + $previousmonth = ''; } else { $previousmode = $obj->mode; + $previousmonth = $obj->dm; } $i++; @@ -154,7 +157,7 @@ function pt ($db, $sql, $date) if ($obj->mode == 'claimed' && ! empty($previousmode)) { print ''; - print '\n"; + print '\n"; print '\n"; print '\n"; print "\n"; @@ -534,7 +537,7 @@ $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; $sql.= " GROUP BY dm"; -$sql.= " ORDER BY dm ASC"; +$sql.= " ORDER BY dm ASC, mode ASC"; //print $sql; pt($db, $sql, $langs->trans("Month")); From 630e38072b84c68a3a4dd5ebc927e78f7b11ac74 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 15 May 2018 17:02:54 +0200 Subject: [PATCH 139/183] fix SQL and add hook --- htdocs/projet/contact.php | 37 +++++++++++++++++++------------------ htdocs/projet/element.php | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 72b82ac2bb0..6da1028d473 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -49,6 +49,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id,'projet&project'); +$hookmanager->initHooks(array('projectcontactcard','globalcard')); /* * Actions @@ -150,26 +151,26 @@ if ($id > 0 || ! empty($ref)) // Project card - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Title $morehtmlref.=$object->title; // Thirdparty - if ($object->thirdparty->id > 0) + if ($object->thirdparty->id > 0) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -178,7 +179,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print '
'.$langs->trans("FoundCats").'
'.$langs->trans("Size").'
'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).''.img_edit().''; + print ''.img_edit().''; print "  ".img_delete()."
'.$obj->nb.''; + if ($obj->socid) print ''.$obj->nb.''; + else print ''.$obj->nb.''; + print '
'; + print $langs->trans('WEBSITE_TITLE'); + print ''; + print ''; + print '
'; print $langs->trans('WEBSITE_PAGENAME'); print ''; @@ -2055,12 +2063,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '
'; - print $langs->trans('WEBSITE_TITLE'); - print ''; - print ''; - print '
'; print $langs->trans('WEBSITE_DESCRIPTION'); print ''; From d52305cef86e61da2391d8aa13e618231fc8d076 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 11:50:42 +0200 Subject: [PATCH 137/183] NEW Add entry for the GDPR contact --- htdocs/admin/company.php | 15 ++++++++++++++- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 59fa9eeae2f..dfa4b043978 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand @@ -157,6 +157,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'nohtml'),'chaine',0,'',$conf->entity); @@ -424,6 +425,13 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'; + print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); + print ''; + print '
'; @@ -815,6 +823,11 @@ else print '
'.$langs->trans("ManagingDirectors").''; print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '
'.$langs->trans("GDPRContact").''; + print $conf->global->MAIN_INFO_GDPR . '
'.$langs->trans("Capital").''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9be2b2d4de1..563b63ef7b9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1793,6 +1793,8 @@ EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous fie SeveralLangugeVariatFound=Several language variants found COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) +GDPRContact=GDPR contact +GDPRContactDesc=If you store data about European companies/citizen, you can store here the contact who is responsible for the General Data Protection Regulation ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From 7099068f055f0955feb53f2c54b571dc9e819bae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 14:47:04 +0200 Subject: [PATCH 138/183] Fix calculation of vat paid --- htdocs/compta/tva/index.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 3597ad27c92..e6cdf738b96 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -105,14 +105,15 @@ function pt ($db, $sql, $date) $amountclaimed = 0; $amountpaid = 0; + $previousmonth = ''; $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); - + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; if ($obj->mode == 'claimed' && ! empty($previousmode)) { print '
'.$obj->dm."'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'; - + // Visibility print ''; - + // Opportunity percent print ''; } - + // Date start - end print '
'.$langs->trans("Visibility").''; if ($object->public) print $langs->trans('SharedProject'); @@ -192,7 +193,7 @@ if ($id > 0 || ! empty($ref)) $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) print $langs->trans("OppStatus".$code); print '
'.$langs->trans("OpportunityProbability").''; if (strcmp($object->opp_percent,'')) print price($object->opp_percent,'',$langs,1,0).' %'; @@ -203,7 +204,7 @@ if ($id > 0 || ! empty($ref)) if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,0,0,0,$conf->currency); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start,'dayhour'); @@ -222,40 +223,40 @@ if ($id > 0 || ! empty($ref)) // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print "
"; print ''; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if ($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($object->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($object->id,'project',1); print "
'; - + print '
'; print '
'; print ''; - + print '
'; - + dol_fiche_end(); - + print '
'; - + // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 17b3cbd65f9..85bbf906fef 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -145,7 +145,7 @@ $morehtmlref.=''; if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; + $object->next_prev_filter=" te.rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); From 3e27d7dd2a3888811080d71179c971fc16f213af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 17:51:19 +0200 Subject: [PATCH 140/183] Report of turnover by vat rate / product type / country --- htdocs/compta/stats/byratecountry.php | 361 ++++++++++++++++++++++++ htdocs/compta/stats/cabyprodserv.php | 49 ++-- htdocs/compta/stats/casoc.php | 4 +- htdocs/compta/stats/index.php | 6 +- htdocs/core/menus/standard/eldy.lib.php | 3 +- htdocs/langs/en_US/accountancy.lang | 1 + htdocs/langs/en_US/compta.lang | 10 +- htdocs/langs/en_US/main.lang | 2 +- 8 files changed, 401 insertions(+), 35 deletions(-) create mode 100644 htdocs/compta/stats/byratecountry.php diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php new file mode 100644 index 00000000000..b2186633413 --- /dev/null +++ b/htdocs/compta/stats/byratecountry.php @@ -0,0 +1,361 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2006-2007, 2015 Yannick Warnier + * Copyright (C) 2014 Ferran Marcet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/tva/quadri_detail.php + * \ingroup tax + * \brief VAT by rate + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; + +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); + +$modecompta = GETPOST('modecompta','alpha'); + +// Date range +$year=GETPOST("year",'int'); +$month=GETPOST("month",'int'); +if (empty($year)) +{ + $year_current = strftime("%Y",dol_now()); + $month_current = strftime("%m",dol_now()); + $year_start = $year_current; +} else { + $year_current = $year; + $month_current = strftime("%m",dol_now()); + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q","int"); + if (empty($q)) + { + // We define date_start and date_end + $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_end=$year_start; + $month_end=$month_start; + if (! GETPOST("month")) // If month not forced + { + if (! GETPOST('year') && $month_start > $month_current) + { + $year_start--; + $year_end--; + } + $month_end=$month_start-1; + if ($month_end < 1) $month_end=12; + else $year_end++; + } + $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } +} + +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; + +$tmp_date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; +if ($tmp_date_end < $date_end || $date_end < $date_start) $date_end = $tmp_date_end; + +$min = price2num(GETPOST("min","alpha")); +if (empty($min)) $min = 0; + +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', '', '', 'charges'); + + + +/* + * View + */ + +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + +$morequerystring=''; +$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); +foreach ($listofparams as $param) +{ + if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); +} + +llxHeader('',$langs->trans("TurnoverReport"),'','',0,0,'','',$morequerystring); + + +//print load_fiche_titre($langs->trans("VAT"),""); + +//$fsearch.='
'; +$fsearch.=' '; +$fsearch.=' '; +//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; +//$fsearch.=' '; + + +// Show report header +$name=$langs->trans("xxx"); +$calcmode=''; +if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); +$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; +} +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; +} +$description.=$fsearch; +$builddate=dol_now(); + +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.='
'.$langs->trans("DepositsAreNotIncluded"); +} +if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +// Customers invoices +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("ProductOrService"); +$amountcust=$langs->trans("AmountHT"); + +// Suppliers invoices +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$productcust; +$amountsup=$amountcust; +$namesup=$namecust; + + + + +// Show report header +$name=$langs->trans("SalesTurnover").', '.$langs->trans("ByVatRate"); + +if ($modecompta=="CREANCES-DETTES") { + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + + $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.= $langs->trans("DepositsAreNotIncluded"); + } else { + $description.= $langs->trans("DepositsAreIncluded"); + } + + $builddate=dol_now(); +} else { + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + + $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); + + $builddate=dol_now(); +} +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; + +$description.=' '; + +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); + +if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +{ + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); +} + + +if ($modecompta == 'CREANCES-DETTES') +{ + +print ''; +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT fd.tva_tx AS vatrate,"; +$sql .= " fd.product_type AS product_type,"; +$sql .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; +$sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND f.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND f.type IN (0,1,2,5)"; +} else { + $sql.= " AND f.type IN (0,1,2,3,5)"; +} +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; +$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; + +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql2 = "SELECT ffd.tva_tx AS vatrate,"; +$sql2 .= " ffd.product_type AS product_type,"; +$sql2 .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql2 .= " SUM(ffd.total_ht) as total"; +$sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; +$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; +$sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND ff.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND ff.type IN (0,1,2,5)"; +} else { + $sql.= " AND ff.type IN (0,1,2,3,5)"; +} +$sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; +$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; + +//print $sql2; +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql2 = $db->query($sql2); +if ($resql2) { + $num = $db->num_rows($resql2); + + while ( $row = $db->fetch_row($resql2)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql2); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
\n"; + +} else { + // $modecompta != 'CREANCES-DETTES' + // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an + // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? + // Because there is no way to know this, this report is not relevant. + print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
'; +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 1c170eae96d..e4d1f16cb8b 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("products"); -$langs->load("categories"); -$langs->load("errors"); +$langs->loadLangs(array("products","categories","errors",'accountancy')); // Security pack (data & check) $socid = GETPOST('socid','int'); @@ -78,13 +76,13 @@ if (empty($year)) $month_current = strftime("%m",dol_now()); $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int"); + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); @@ -103,10 +101,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } else { // TODO We define q } @@ -188,7 +189,7 @@ report_header($name,$namelink,$period,$periodlink,$description,$builddate,$expor if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { - print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } @@ -205,17 +206,17 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; if ($selected_cat === -2) // Without any category { - $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } else if ($selected_cat) // Into a specific category { $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } - $sql.= " WHERE l.fk_product = p.rowid"; - $sql.= " AND l.fk_facture = f.rowid"; + $sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; @@ -363,23 +364,21 @@ if ($modecompta == 'CREANCES-DETTES') ); print "
"; $fullname=$name[$key]; - if ($key >= 0) { + if ($key > 0) { $linkname=''.img_object($langs->trans("ShowProduct"),$type[$key]==0?'product':'service').' '.$fullname.''; } else { $linkname=$langs->trans("PaymentsNotLinkedToProduct"); } - - print "".$linkname."'; @@ -423,11 +422,11 @@ if ($modecompta == 'CREANCES-DETTES') // Total print '
'.$langs->trans("Total").''.price($qtytotal).' '.$qtytotal.'100%'.price($catotal_ht).''.price($catotal).' 100%
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4d3951f7b5e..6a77e4661d5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -699,7 +699,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } - } /* @@ -1103,6 +1102,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report", $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire); } // Accountancy (simple) @@ -1131,6 +1131,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=report",$langs->trans("ByCompanies"),2,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report",$langs->trans("ByUsers"),2,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"),2,$user->rights->compta->resultat->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report", $langs->trans("ByVatRate"),2,$user->rights->compta->resultat->lire); // Journaux //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a7b7e345682..7207110ce42 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -192,6 +192,7 @@ ListAccounts=List of the accounting accounts UnknownAccountForThirdparty=Unknown third party account. We will use %s UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third party account and waiting account not defined. Blocking error +PaymentsNotLinkedToProduct=Payment not linked to any product / service Pcgtype=Group of account Pcgsubtype=Subgroup of account diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 9c1574c77ef..db9b4d481e8 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -210,7 +210,7 @@ Pcg_version=Chart of accounts models Pcg_type=Pcg type Pcg_subtype=Pcg subtype InvoiceLinesToDispatch=Invoice lines to dispatch -ByProductsAndServices=By products and services +ByProductsAndServices=By product and service RefExt=External ref ToCreateAPredefinedInvoice=To create a template invoice, create a standard invoice, then, without validating it, click onto button "%s". LinkedOrder=Link to order @@ -218,7 +218,8 @@ Mode1=Method 1 Mode2=Method 2 CalculationRuleDesc=To calculate total VAT, there is two methods:
Method 1 is rounding vat on each line, then summing them.
Method 2 is summing all vat on each line, then rounding result.
Final result may differs from few cents. Default mode is mode %s. CalculationRuleDescSupplier=According to supplier, choose appropriate method to apply same calculation rule and get same result expected by your supplier. -TurnoverPerProductInCommitmentAccountingNotRelevant=Turnover report per product, when using a cash accountancy mode is not relevant. This report is only available when using engagement accountancy mode (see setup of accountancy module). +TurnoverPerProductInCommitmentAccountingNotRelevant=Turnover report per product, when using a cash accounting mode is not relevant. This report is only available when using commitment accounting mode (see setup of accountancy module). +TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant=Turnover report per sale tax rate, when using a cash accounting mode is not relevant. This report is only available when using commitment accounting mode (see setup of accountancy module). CalculationMode=Calculation mode AccountancyJournal=Accounting code journal ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for VAT on sales (used if not defined on VAT dictionary setup) @@ -248,4 +249,7 @@ AccountingAffectation=Accounting assignement LastDayTaxIsRelatedTo=Last day of period the tax is related to VATDue=Sale tax claimed ClaimedForThisPeriod=Claimed for the period -PaidDuringThisPeriod=Paid during this period \ No newline at end of file +PaidDuringThisPeriod=Paid during this period +ByVatRate=By sale tax rate +TurnoverbyVatrate=Turnover by sale tax rate +PurchasebyVatrate=Purchase by sale tax rate \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 60369b80ea5..77e9c04b10a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -494,7 +494,7 @@ Received=Received Paid=Paid Topic=Subject ByCompanies=By third parties -ByUsers=By users +ByUsers=By user Links=Links Link=Link Rejects=Rejects From ad32b3098acdd45c1d8b574f758efb838a955516 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 10:31:44 +0200 Subject: [PATCH 141/183] Too verbose log --- htdocs/core/class/translate.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 55b853f5c8e..3602ae427bd 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -542,7 +542,7 @@ class Translate */ private function getTradFromKey($key) { - global $db; + global $conf, $db; if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. @@ -576,7 +576,9 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } - dol_syslog(__METHOD__."missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) dol_syslog(__METHOD__." missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + return $newstr; } From ef395fc36bbd74a451a7e79c3af5947a3f190b3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 15:23:52 +0200 Subject: [PATCH 142/183] Fix scrutinizer bugs --- htdocs/asset/class/asset.class.php | 2 +- htdocs/categories/class/categorie.class.php | 1 + htdocs/comm/propal/class/propal.class.php | 22 +++++----- .../facture/class/api_invoices.class.php | 2 +- .../facture/class/facture-rec.class.php | 10 +++-- htdocs/compta/localtax/clients.php | 4 +- htdocs/compta/tva/index.php | 7 +++- htdocs/core/lib/security.lib.php | 2 + htdocs/core/lib/tax.lib.php | 2 +- .../modules/printing/printgcp.modules.php | 2 +- htdocs/don/class/don.class.php | 4 +- .../class/fournisseur.commande.class.php | 42 +++++++++---------- .../fourn/class/fournisseur.facture.class.php | 7 ++-- .../template/class/myobject.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/ticketsup/class/api_tickets.class.php | 21 ++++------ 16 files changed, 69 insertions(+), 63 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 86da8ae5379..812c4956187 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -214,7 +214,7 @@ class Asset extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); return $result; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 044f3e68c0f..70b2108dd4c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -895,6 +895,7 @@ class Categorie extends CommonObject $sql.= $this->db->order($sortfield, $sortorder); + $offset = 0; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b6e9d1411c5..f324161a4e7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3081,21 +3081,23 @@ class Propal extends CommonObject */ function LibStatut($statut,$mode=1) { + global $conf; + // Init/load array of translation of status if (empty($this->labelstatut) || empty($this->labelstatut_short)) { global $langs; $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + $this->labelstatut[0]=$langs->trans("PropalStatusDraft"); + $this->labelstatut[1]=$langs->trans("PropalStatusValidated"); + $this->labelstatut[2]=$langs->trans("PropalStatusSigned"); + $this->labelstatut[3]=$langs->trans("PropalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("PropalStatusBilled"); + $this->labelstatut_short[0]=$langs->trans("PropalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("PropalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("PropalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort"); } $statuttrans=''; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 8547be8cb2c..2c744b8bda3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1074,7 +1074,7 @@ class Invoices extends DolibarrApi * Warning: Take care that all invoices are owned by the same customer. * Example of value for parameter arrayofamounts: {"1": "99.99", "2": "10"} * - * @param string $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice + * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index e52658d38e8..40205ff0a97 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -979,6 +979,8 @@ class FactureRec extends CommonInvoice { global $conf, $langs, $db, $user; + $error=0; + $langs->load("bills"); $nb_create=0; @@ -1010,11 +1012,13 @@ class FactureRec extends CommonInvoice while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. { - $line = $db->fetch_object($resql); + $line = $db->fetch_object($resql); $db->begin(); - $facturerec = new FactureRec($db); + $invoiceidgenerated = 0; + + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); if ($facturerec->id > 0) @@ -1024,8 +1028,6 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); - $error=0; - $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 3c8a2a9aef6..dadb5ee5e5d 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -164,7 +164,7 @@ if($calc ==0 || $calc == 2) print "
".$vatcust."
'.$previousmonth."
"; + $db->free($result); } else { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 502f962dede..d157cafd5f8 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -38,6 +38,7 @@ function dol_encode($chain, $key='1') { if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { + $output_tab=array(); $strlength=dol_strlen($chain); for ($i=0; $i < $strlength; $i++) { @@ -75,6 +76,7 @@ function dol_decode($chain, $key='1') if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { + $output_tab=array(); $strlength=dol_strlen($chain); for ($i=0; $i < $strlength;$i++) { diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 0d46503c51b..57bb32ef1a3 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -580,7 +580,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $paymentfacturetable='paiement_facture'; $invoicefieldref='facnumber'; } - if ($direction == 'buy') + else { $invoicetable='facture_fourn'; $invoicedettable='facture_fourn_det'; diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index d2db656a6f2..c8c765e454d 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -482,7 +482,7 @@ class printing_printgcp extends PrintingDriver } else { - $html .= '
'.$langs->trans("None").'
'; - print $langs->trans('SituationAmount'); - print ' '; - - print $prevsits[0]->situation_counter; - $cprevsits = count($prevsits); - - for ($i = 1; $i < $cprevsits; $i++) { - print ' + '; - print $prevsits[$i]->situation_counter; - } - print ' + '; - print $object->situation_counter; - - print ''; - - $prevsits_total_amount = 0; - foreach ($prevsits as $situation) { - $prevsits_total_amount += $situation->total_ht; - } - $prevsits_total_amount += $object->total_ht; - - print price($prevsits_total_amount, 0, $langs, 1, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency) ); - - print '
'; - print ''; - print $langs->trans('SituationDeduction'); - print ' '; - print $prevsits[$i]->situation_counter; - print ''; - print '- ' . price($prevsits[$i]->total_ht, 0, $langs, 1, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency) ); - print '
'; - - - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - $total_prev_ht = $total_prev_ttc = 0; - $total_global_ht = $total_global_ttc = 0; - - if (count($object->tab_previous_situation_invoice) > 0) { - // List of previous invoices - - $current_situation_counter = array(); - foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $totalpaye = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } - } - - - $total_global_ht += $total_prev_ht ; - $total_global_ttc += $total_prev_ttc ; - $total_global_ht += $object->total_ht; - $total_global_ttc += $object->total_ttc; - $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $object->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - - if (count($object->tab_next_situation_invoice) > 0) { - // List of next invoices - /*print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print '';*/ - - $total_next_ht = $total_next_ttc = 0; - - foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - } - - $total_global_ht += $total_next_ht; - $total_global_ttc += $total_next_ttc; - - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } - - print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . $object->getNomUrl(1) . ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.'' . price($object->total_ht) . '' . price($object->total_ttc) . '' . $object->getLibStatut(3, $object->getSommePaiement()) . '
' . $langs->trans('CurrentSituationTotal') . ''; - $i =0; - foreach ($current_situation_counter as $sit) - { - $curSign = $sit>0?'+':'-'; - $curType = $sit>0?$langs->trans('situationInvoiceShortcode_S'):$langs->trans('situationInvoiceShortcode_AS'); - if($i>0) print ' '.$curSign.' '; - print $curType . abs($sit); - $i++; - } - print '' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
'; - } + // Incoterms if (!empty($conf->incoterm->enabled)) @@ -4170,88 +4000,129 @@ else if ($id > 0 || ! empty($ref)) if (! empty($conf->incoterm->enabled)) $nbrows += 1; - if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) + // List of previous situation invoices + if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) { - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) - print ''; - - if (count($object->tab_previous_situation_invoice) > 0) { - // List of previous invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - $total_prev_ht = $total_prev_ttc = 0; - foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $totalpaye = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - } - - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_next_situation_invoice) > 0) { - // List of next invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - $total_next_ht = $total_next_ttc = 0; - - foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - - } - - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) - print '
' . $langs->trans('ListOfPreviousSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . '' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_prev_ht) . '' . price($total_prev_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . '' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_next_ht) . '' . price($total_next_ttc) . ' 
'; + + print ''; + + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; + + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices + + $current_situation_counter = array(); + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $totalpaye = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } + } + + + $total_global_ht += $total_prev_ht ; + $total_global_ttc += $total_prev_ttc ; + $total_global_ht += $object->total_ht; + $total_global_ttc += $object->total_ttc; + $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $object->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + /*print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print '';*/ + + $total_next_ht = $total_next_ttc = 0; + + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaye = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + + } + + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; + + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } + + print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('Situation') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . $object->getNomUrl(1) . ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.'' . price($object->total_ht) . '' . price($object->total_ttc) . '' . $object->getLibStatut(3, $object->getSommePaiement()) . '
' . $langs->trans('CurrentSituationTotal') . ''; + $i =0; + foreach ($current_situation_counter as $sit) + { + $curSign = $sit>0?'+':'-'; + $curType = $sit>0?$langs->trans('situationInvoiceShortcode_S'):$langs->trans('situationInvoiceShortcode_AS'); + if($i>0) print ' '.$curSign.' '; + print $curType . abs($sit); + $i++; + } + print '' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_global_ht) . '' . price($total_global_ttc) . ' 
'; } From 4a0195deeea99add4f9addc8e4d286a13e11e2b8 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 May 2018 15:55:56 +0200 Subject: [PATCH 144/183] Fix merge mistake --- htdocs/compta/facture/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 60ed4386b66..3722490e750 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -926,7 +926,6 @@ if (empty($reshook)) } $id = $object->create($user); - $facture_source = new Facture($db); // fetch origin object if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) { if (!empty($facture_source->lines)) From c67ab2a758d8999a40706014dbc98dc853b9afcc Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 May 2018 16:14:49 +0200 Subject: [PATCH 145/183] add hidden conf --- htdocs/compta/facture/class/facture.class.php | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7403804b179..67b24b4d7b2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3502,16 +3502,6 @@ class Facture extends CommonInvoice $return = array(); - // Select the last situation invoice - $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit.= " WHERE fs.entity = ".$conf->entity; - $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; - $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sqlSit.= " GROUP BY fs.situation_cycle_ref"; - $sqlSit.= " ORDER BY fs.situation_counter"; - - $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; @@ -3523,7 +3513,23 @@ class Facture extends CommonInvoice // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + + if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ + // Select the last situation invoice + $sqlSit = 'SELECT MAX(fs.rowid)'; + $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit.= " WHERE fs.entity = ".$conf->entity; + $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; + $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit.= " GROUP BY fs.situation_cycle_ref"; + $sqlSit.= " ORDER BY fs.situation_counter"; + $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + } + else + { + $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir + } + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; $sql.= " ORDER BY f.facnumber"; From fddd3156b103e5201ea4c1046a475153f1e843fe Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 May 2018 16:15:30 +0200 Subject: [PATCH 146/183] add hidden conf --- htdocs/compta/facture/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3722490e750..98b3c3528f4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4683,6 +4683,7 @@ else if ($id > 0 || ! empty($ref)) && $user->rights->facture->creer && !$objectidnext && $object->is_last_in_cycle() + && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE ) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) From 5c727c077b34a335f0a4916c18440b3db1464b9c Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Wed, 16 May 2018 16:34:19 +0200 Subject: [PATCH 147/183] fix task contact card without withproject parameters --- htdocs/projet/tasks/contact.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index a2db82fc0ed..fad5466cb7f 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -303,6 +303,7 @@ if ($id > 0 || ! empty($ref)) // Project if (empty($withproject)) { + $result=$projectstatic->fetch($object->fk_project); $morehtmlref.='
'; $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); @@ -310,7 +311,11 @@ if ($id > 0 || ! empty($ref)) // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + if($projectstatic->socid>0) { + $projectstatic->fetch_thirdparty(); + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref.='
'; } From ac97ba9e36f5a65d54368d361468f3013b68ddb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 20:41:01 +0200 Subject: [PATCH 148/183] Fix deletion of stripe card Solve validation of recurring invoice --- htdocs/compta/facture/class/facture-rec.class.php | 12 ++++++++---- htdocs/societe/paymentmodes.php | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 40205ff0a97..dbf15ff0186 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -973,9 +973,11 @@ class FactureRec extends CommonInvoice * * WARNING: This method change temporarly context $conf->entity to be in correct context for each recurring invoice found. * - * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) + * @param int $restictoninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID + * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. + * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function createRecurringInvoices() + function createRecurringInvoices($restictoninvoiceid=0, $forcevalidation=0) { global $conf, $langs, $db, $user; @@ -989,13 +991,15 @@ class FactureRec extends CommonInvoice $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - dol_syslog("createRecurringInvoices"); + dol_syslog("createRecurringInvoices restictoninvoiceid=".$restictoninvoiceid." forcevalidation=".$forcevalidation); + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= ' AND suspended = 0'; $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here + if ($restictoninvoiceid > 0) $sql.=' AND rowid = '.$restictoninvoiceid; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; @@ -1044,7 +1048,7 @@ class FactureRec extends CommonInvoice $this->error = $facture->error; $error++; } - if (! $error && $facturerec->auto_validate) + if (! $error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); if ($result <= 0) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 0baffe090d2..8b11ab9573b 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -614,7 +614,7 @@ if (empty($reshook)) setEventMessages($e->getMessage(), null, 'errors'); } } - elseif ($action == 'deletecard') + elseif ($action == 'deletecard' && $source) { try { $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); @@ -918,7 +918,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print img_picto($langs->trans("Modify"),'edit'); print ''; print ' '; - print ''; + print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& print img_picto($langs->trans("Delete"), 'delete'); print ''; } From 133e736801b9dbb0268634dd7214864a00fa2136 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 20:52:45 +0200 Subject: [PATCH 149/183] Fix save code --- htdocs/comm/action/class/actioncomm.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5234a05db43..261948ab190 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -281,6 +281,7 @@ class ActionComm extends CommonObject return -1; } } + $code = empty($this->code)?$this->type_code:$this->code; // Check parameters if (! $this->type_id) @@ -316,7 +317,7 @@ class ActionComm extends CommonObject $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").", "; $sql.= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '')?"'".$this->db->escape($this->durationp)."'":"null").", "; // deprecated $sql.= (isset($this->type_id)?$this->type_id:"null").","; - $sql.= (isset($this->type_code)?" '".$this->db->escape($this->type_code)."'":"null").", "; + $sql.= ($code?("'".$code."'"):"null").", "; $sql.= ((isset($this->socid) && $this->socid > 0) ? $this->socid:"null").", "; $sql.= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project:"null").", "; $sql.= " '".$this->db->escape($this->note)."', "; From 67ed1e0841f5fa5fccdaec378ead6b3127a8b1ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 20:59:45 +0200 Subject: [PATCH 150/183] Fix filter criteria when using backto for events --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fb9c5944baf..e13b6bc382f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1291,7 +1291,7 @@ if ($id > 0) } $linkback =img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); - $linkback.= ''.$langs->trans("BackToList").''; + $linkback.= ''.$langs->trans("BackToList").''; // Link to other agenda views $out=''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 261948ab190..be9c6f98489 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1203,15 +1203,16 @@ class ActionComm extends CommonObject * Return URL of event * Use $this->id, $this->type_code, $this->label and $this->type_label * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. - * @param string $classname Force style class on a link - * @param string $option ''=Link to action, 'birthday'=Link to contact - * @param int $overwritepicto 1=Overwrite picto - * @param int $notooltip 1=Disable tooltip - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. + * @param string $classname Force style class on a link + * @param string $option ''=Link to action, 'birthday'=Link to contact + * @param int $overwritepicto 1=Overwrite picto + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto=0, $notooltip=0) + function getNomUrl($withpicto=0, $maxlength=0, $classname='', $option='', $overwritepicto=0, $notooltip=0, $save_lastsearch_value=-1) { global $conf, $langs, $user, $hookmanager, $action; @@ -1275,6 +1276,13 @@ class ActionComm extends CommonObject $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } $linkstart = ''; From 933e277862d63ed87728b0f45978b4d25789f3aa Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Wed, 16 May 2018 19:56:01 +0100 Subject: [PATCH 151/183] Fix: Add journal label translation in journal list --- htdocs/accountancy/admin/journals_list.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index f43eb6c7444..f050b76e2d6 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -600,6 +600,7 @@ if ($id) if (empty($reshook)) { + $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { @@ -610,10 +611,13 @@ if ($id) $valuetoshow=$langs->trans('All'); } else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { - $langs->loadLangs(array("accountancy")); $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); - $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]}); + $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]}); + $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]}); } + else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { + $valuetoshow=$langs->trans($obj->label); + } $class='tddict'; // Show value for field From 8175d908162fba49ac99c930ee1bbfb5af47c62b Mon Sep 17 00:00:00 2001 From: John Date: Thu, 17 May 2018 09:01:49 +0200 Subject: [PATCH 152/183] change case --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 98b3c3528f4..5e204ab3231 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2191,7 +2191,7 @@ if (empty($reshook)) // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id,'', '','', TRUE); + $object->fetch($id,'', '','', true); if ($object->statut == Facture::STATUS_VALIDATED && $object->type == Facture::TYPE_SITUATION From 200af6ea5cbd9baa319d810a48acb391610e1356 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 09:45:31 +0200 Subject: [PATCH 153/183] Fix stripe link --- htdocs/cron/card.php | 2 ++ htdocs/societe/paymentmodes.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 7730f6aafe4..42a0e881512 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -710,7 +710,9 @@ else print '
'; print $langs->trans('CronLastResult').""; + if ($object->lastresult) print ''; print $object->lastresult; + if ($object->lastresult) print ''; print "
'; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 8b11ab9573b..9b9ac758fa7 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -758,7 +758,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; //print $stripecu; print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if ($stripecu) + if ($stripecu && $action != 'editkey_account') { $url='https://dashboard.stripe.com/test/customers/'.$stripecu; if ($servicestatus) From 5804d1d4a302915551f97aef1006d8f4fb7d2a0f Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 17 May 2018 10:16:44 +0200 Subject: [PATCH 154/183] Fix missing params for commonGenerateDocument ADD param moreparams for compatibility with commonGenerateDocument --- htdocs/compta/facture/class/facture.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b73307277c8..1d4dd3a45a9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2013 Cedric Gross * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -3979,9 +3980,10 @@ class Facture extends CommonInvoice * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information * @return int <0 if KO, >0 if OK */ - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) { global $conf,$langs; @@ -4000,7 +4002,7 @@ class Facture extends CommonInvoice $modelpath = "core/modules/facture/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } /** From 1645c14e25664cbdd4f2e6fc80919298c0055e71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 13:51:17 +0200 Subject: [PATCH 155/183] Fix deletion of stripe card --- .../interface_80_modStripe_Stripe.class.php | 93 +++++++++++-------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 7d4680be3f9..2e9cfda1cd8 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -119,13 +119,13 @@ class InterfaceStripe $langs->load("mails"); $langs->load('other'); - $ok = 0; - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); if (empty($conf->stripe->enabled)) return 0; + $ok = 1; + $service = 'StripeTest'; $servicestatus = 0; if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) @@ -175,28 +175,38 @@ class InterfaceStripe if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this + if (! empty($object->stripe_card_ref)) + { + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - if ($stripecu) { - // Get customer (required to get a card) - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $customer = \Stripe\Customer::retrieve($stripecu); - } else { - $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); - } - - if ($customer) + if (empty($stripeacc)) { - $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); - if ($card) { - $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])); - try { - $card->save($dataforcard); - } - catch(Exception $e) - { - $this->error = $e->getMessages(); + $ok = -1; + $this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service; + } + elseif ($stripecu) + { + // Get customer (required to get a card) + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $customer = \Stripe\Customer::retrieve($stripecu); + } else { + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); + } + + if ($customer) + { + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); + if ($card) { + $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])); + try { + $card->save($dataforcard); + } + catch(Exception $e) + { + $ok = -1; + $this->error = $e->getMessages(); + } } } } @@ -205,24 +215,31 @@ class InterfaceStripe if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - - if ($stripecu) + if (! empty($object->stripe_card_ref)) { - // Get customer (required to get a card) - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $customer = \Stripe\Customer::retrieve($stripecu); - } else { - $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); - } - - if ($customer) + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this + if (empty($stripeacc)) { - $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); - if ($card) { - if (method_exists($card, 'detach')) $card->detach(); - else $card->delete(); + $ok = -1; + $this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service; + } + elseif ($stripecu) + { + // Get customer (required to get a card) + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $customer = \Stripe\Customer::retrieve($stripecu); + } else { + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); + } + + if ($customer) + { + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); + if ($card) { + if (method_exists($card, 'detach')) $card->detach(); + else $card->delete(); + } } } } From 4f6b0fead6468ecb318bab629339bb8d64340c07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 15:13:16 +0200 Subject: [PATCH 156/183] Fix filter on test/live mode for stripe card --- htdocs/societe/paymentmodes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 9b9ac758fa7..0a2df0d3d87 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -841,6 +841,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; $sql.=" WHERE type in ('card', 'paypal')"; $sql.=" AND fk_soc = ".$object->id; + $sql.=" AND status = ".$servicestatus; $resql = $db->query($sql); if ($resql) From ffb6a5db8142a5895cf9d08fb60777f9c9fc5e6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 16:07:44 +0200 Subject: [PATCH 157/183] Fix use correct stripe env --- htdocs/stripe/class/stripe.class.php | 39 +++++++++++++++++++--------- htdocs/stripe/config.php | 21 +++++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 3b53b4572f0..c28567c8416 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -135,7 +135,7 @@ class Stripe extends CommonObject $sql.= " AND sa.site = 'stripe' AND sa.status = ".((int) $status); $sql.= " AND key_account IS NOT NULL AND key_account <> ''"; - dol_syslog(get_class($this) . "::fetch search stripe customer id for thirdparty id=".$object->id, LOG_DEBUG); + dol_syslog(get_class($this) . "::customerStripe search stripe customer id for thirdparty id=".$object->id, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -143,6 +143,13 @@ class Stripe extends CommonObject { $obj = $this->db->fetch_object($resql); $tiers = $obj->key_account; + + dol_syslog(get_class($this) . "::customerStripe found stripe customer key_account = ".$tiers); + + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + try { if (empty($key)) { // If the Stripe connect account not set, we use common API usage $customer = \Stripe\Customer::retrieve("$tiers"); @@ -167,6 +174,10 @@ class Stripe extends CommonObject //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($key);exit; try { + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + if (empty($key)) { // If the Stripe connect account not set, we use common API usage $customer = \Stripe\Customer::create($dataforcustomer); } else { @@ -373,6 +384,10 @@ class Stripe extends CommonObject ); $return = new Stripe($this->db); try { + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + if (empty($conf->stripeconnect->enabled)) { if (preg_match('/acct_/i', $source)) @@ -410,17 +425,17 @@ class Stripe extends CommonObject } $charge = \Stripe\Charge::create(array( - "amount" => "$stripeamount", - "currency" => "$currency", - // "statement_descriptor" => " ", - "description" => "$description", - "metadata" => $metadata, - "source" => "$source", - "customer" => "$customer", - "application_fee" => "$fee" - ), array( - "idempotency_key" => "$ref", - "stripe_account" => "$account" + "amount" => "$stripeamount", + "currency" => "$currency", + // "statement_descriptor" => " ", + "description" => "$description", + "metadata" => $metadata, + "source" => "$source", + "customer" => "$customer", + "application_fee" => "$fee" + ), array( + "idempotency_key" => "$ref", + "stripe_account" => "$account" )); } if (isset($charge->id)) {} diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index db982e878f9..1e9eb7a5181 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -30,22 +30,27 @@ require_once DOL_DOCUMENT_ROOT.'/includes/stripe/lib/Stripe.php'; global $stripe; global $conf; +global $stripearrayofkeysbyenv; +$stripearrayofkeysbyenv = array( + 0=>array( + "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY + ), + 1=>array( + "secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY + ) +); $stripearrayofkeys = array(); if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')) { - $stripearrayofkeys = array( - "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY - ); + $stripearrayofkeys = $stripearrayofkeysbyenv[0]; } else { - $stripearrayofkeys = array( - "secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY - ); + $stripearrayofkeys = $stripearrayofkeysbyenv[1]; } \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); From a23d1f6b82c0ca3285e66093cbda3ea0d4352b42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 16:50:40 +0200 Subject: [PATCH 158/183] Code comment --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 18a236056b9..f751711288c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -418,7 +418,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } }*/ - // Initialisation of datas + // Initialisation of datas of object to call trigger if (is_object($object)) { if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically From a279451241805d401e4d04b2d7d47bd1e650e2e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 17:58:29 +0200 Subject: [PATCH 159/183] Fix can use actionmsg for generic trigger --- htdocs/core/class/html.formsms.class.php | 2 +- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 103b40e33df..6db6f200136 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -213,7 +213,7 @@ function limitChars(textarea, limit, infodiv) else { $sms = new stdClass(); - $sms->error='The SMS manager '.$classfile.' defined into SMS setup MAIN_SMS_SENDMODE is not found'; + $sms->error='The SMS manager "'.$classfile.'" defined into SMS setup MAIN_SMS_SENDMODE is not found'; } } catch(Exception $e) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 2301b1642b4..481df585f3a 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -809,7 +809,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); - $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); + if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); $object->sendtoid=0; } From 1581e73906f2d81bdfcd0e8953df6593aa35164c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 May 2018 18:04:30 +0200 Subject: [PATCH 160/183] Trans --- htdocs/langs/en_US/other.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 04b38e531ef..a2039c995a2 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -233,6 +233,8 @@ PermissionsDelete=Permissions removed YourPasswordMustHaveAtLeastXChars=Your password must have at least %s chars YourPasswordHasBeenReset=Your password has been reset successfully ApplicantIpAddress=IP address of applicant +SMSSentTo=SMS sent to %s + ##### Export ##### ExportsArea=Exports area AvailableFormats=Available formats From dc7a1610e78d89e7489eaff5da52214882076f03 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 17 May 2018 18:56:01 +0200 Subject: [PATCH 161/183] Fix: extrafiels is not passing orders to invoice --- htdocs/commande/orderstoinvoice.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 40071a0b21d..49a6a88a78f 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Andreu Bisquerra Gaya * Copyright (C) 2012 David Rodriguez Martinez - * Copyright (C) 2012-2017 Juanjo Menent + * Copyright (C) 2012-2018 Juanjo Menent * Copyright (C) 2015 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -285,6 +285,13 @@ if (($action == 'create' || $action == 'add') && !$error) { $fk_parent_line = 0; } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $result = $object->addline( $desc, $lines[$i]->subprice, @@ -309,7 +316,8 @@ if (($action == 'create' || $action == 'add') && !$error) $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $lines[$i]->label + $lines[$i]->label, + $array_options ); if ($result > 0) { From 0aa8c6f498eacb95248bb263cc6937ed7921d9d5 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 17 May 2018 19:05:25 +0200 Subject: [PATCH 162/183] Fix: extrafiels is not passing orders to invoice --- htdocs/core/actions_massactions.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5a713168c48..6f07abd2c55 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Juanjo Menent * * 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 @@ -601,6 +602,13 @@ if ($massaction == 'confirm_createbills') { $fk_parent_line = 0; } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -625,7 +633,8 @@ if ($massaction == 'confirm_createbills') $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $lines[$i]->label + $lines[$i]->label, + $array_options ); if ($result > 0) { From 90d2ccc79caff16e5efd4275f514bc8679ce743f Mon Sep 17 00:00:00 2001 From: fappels Date: Thu, 17 May 2018 21:29:15 +0200 Subject: [PATCH 163/183] Fix product vat update error handling Product vat update does not show update error if update result negative. --- htdocs/product/price.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index a2afb5f9bb8..fc5c20c3d1a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -152,7 +152,7 @@ if (empty($reshook)) $db->begin(); $resql = $object->update($object->id, $user); - if (! $resql) + if (! $resql || $resql < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); From 26e10caa7d4fa8ff4ce12b1d2cab6df24621b3c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 09:15:18 +0200 Subject: [PATCH 164/183] FIX #8813 --- htdocs/accountancy/class/accountingaccount.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 6b7e925832b..3f5c11691ad 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -84,7 +84,8 @@ class AccountingAccount extends CommonObject * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { + function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + { global $conf; if ($rowid || $account_number) { @@ -96,10 +97,10 @@ class AccountingAccount extends CommonObject if ($rowid) { $sql .= " a.rowid = '" . $rowid . "'"; } elseif ($account_number) { - $sql .= " a.account_number = '" . $account_number . "'"; + $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; } if (! empty($limittocurrentchart)) { - $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); @@ -203,7 +204,7 @@ class AccountingAccount extends CommonObject $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); $sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); - $sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); + $sql .= ", " . (empty($this->account_category) ? '0' : $this->db->escape($this->account_category)); $sql .= ", " . $user->id; $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active)); $sql .= ")"; @@ -274,7 +275,7 @@ class AccountingAccount extends CommonObject $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; $sql .= " , account_parent = '" . $this->db->escape($this->account_parent) . "'"; $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); - $sql .= " , fk_accounting_category = '" . $this->db->escape($this->account_category) . "'"; + $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : $this->db->escape($this->account_category)); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = " . $this->active; $sql .= " WHERE rowid = " . $this->id; From dd259043cd3522169081bbfd320597f40fc85ad2 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 18 May 2018 09:20:18 +0200 Subject: [PATCH 165/183] Fix: Cashdesk does not apply multi-price or price per customer --- htdocs/cashdesk/facturation_verif.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index ec21de2225d..8867a61e80a 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -1,6 +1,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur + * Copyright (C) 2018 Juanjo Menent * * 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 @@ -145,7 +146,8 @@ switch (GETPOST('action','alpha')) $obj_facturation->id($ret['rowid']); $obj_facturation->ref($ret['ref']); $obj_facturation->stock($ret['reel']); - $obj_facturation->prix($ret['price']); + //$obj_facturation->prix($ret['price']); + $obj_facturation->prix($pu_ht); $vatrate = $tva_tx; From 80bce6b62d43537d56e9baaab4fb11ce573cfbca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 09:25:59 +0200 Subject: [PATCH 166/183] Add phpunit for accountingaccount --- test/phpunit/CommandeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 1d0e4fbf616..443bd1d1932 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -174,7 +174,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * @depends testCommandeFetch * The depends says test is run only if previous is ok */ - public function testCommandUpdate($localobject) + public function testCommandeUpdate($localobject) { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -196,7 +196,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * @param Object $localobject Order * @return Commande * - * @depends testCommandUpdate + * @depends testCommandeUpdate * The depends says test is run only if previous is ok */ public function testCommandeValid($localobject) From 11714b9b6b42719aa429ffa158ae305d9773d6eb Mon Sep 17 00:00:00 2001 From: areaeuro <30721699+areaeuro@users.noreply.github.com> Date: Fri, 18 May 2018 10:27:54 +0200 Subject: [PATCH 167/183] Update societe.class.php Line 2942 throws an error in php 7 "Warning: A non-numeric value encountered" when doing math sum, as substr() may be empty. Convert to intval(substr()) to fix. --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 32f29522268..5766c75b5b8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2939,7 +2939,7 @@ class Societe extends CommonObject //algorithm checking type code CIF $sum = $num[2] + $num[4] + $num[6]; for ($i = 1; $i < 8; $i += 2) - $sum += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1); + $sum += intval(substr((2 * $num[$i]),0,1)) + intval(substr((2 * $num[$i]),1,1)); $n = 10 - substr($sum, strlen($sum) - 1, 1); //Chek special NIF From 3dd11e1eaff09e2d5bcfd96897ddb0ce8789ae65 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 18 May 2018 11:02:04 +0200 Subject: [PATCH 168/183] Fix discount id --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e3e7dc3665f..d79b8d0bae5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1378,7 +1378,7 @@ if (empty($reshook)) // Check if discount not already affected to another invoice if ($discount->fk_facture_line > 0) { - unset($object->lines[$i]); + $line->fk_remise_except = 0; } } } From e2369dea295a2d73df3c18660b42aeee006b350c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 11:17:21 +0200 Subject: [PATCH 169/183] FIX #8722 --- htdocs/compta/facture/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 56b7adc01d5..e3e0f60ce31 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -720,7 +720,6 @@ if (empty($reshook)) $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND pf.fk_paiement = p.rowid'; $sql.= ' AND p.entity IN (' . getEntity('facture').')'; - $sql.= ' ORDER BY p.datep, p.tms'; $resql = $db->query($sql); if (! $resql) dol_print_error($db); From 79bbeb05aed3cb97981b8391cf598a6d046d38fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 11:17:33 +0200 Subject: [PATCH 170/183] Add missing phpunit tests --- test/phpunit/AccountingAccount.php | 225 +++++++++++++++++++++++++++++ test/phpunit/AllTests.php | 3 + 2 files changed, 228 insertions(+) create mode 100644 test/phpunit/AccountingAccount.php diff --git a/test/phpunit/AccountingAccount.php b/test/phpunit/AccountingAccount.php new file mode 100644 index 00000000000..ba7f567b4a0 --- /dev/null +++ b/test/phpunit/AccountingAccount.php @@ -0,0 +1,225 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/AccountingAccount.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/accountancy/class/accountingaccount.class.php'; + +if (empty($user->id)) { + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class AccountingAccountTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return AccountingAccountTest + */ + function __construct() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; die(); } + + print __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + //print $db->getVersion()."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testAccountingAccountCreate + * + * @return void + */ + public function testAccountingAccountCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $localobject->fk_pcg_version = 'PCG99-ABREGE'; + $localobject->account_category = 0; + $localobject->pcg_type = 'XXXXX'; + $localobject->pcg_subtype = 'XXXXX'; + $localobject->account_parent = 0; + $localobject->label = 'Account specimen'; + $localobject->active = 0; + $result=$localobject->create($user); + + $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + return $result; + } + + /** + * testAccountingAccountFetch + * + * @param int $id Id order + * @return AccountingAccount + * + * @depends testAccountingAccountCreate + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountFetch($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $result=$localobject->fetch($id); + + $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + return $localobject; + } + + /** + * testAccountingAccountUpdate + * + * @param Object $localobject AccountingAccount + * @return AccountingAccount + * + * @depends testAccountingAccountFetch + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountUpdate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->label='New label'; + $result=$localobject->update($user); + + $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + return $localobject->id; + } + + /** + * testAccountingAccountDelete + * + * @param int $id Id of order + * @return void + * + * @depends testAccountingAccountUpdate + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); + + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; + } + +} diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index d1f0e8b5158..baf6b960e2b 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -200,6 +200,9 @@ class AllTests require_once dirname(__FILE__).'/CategorieTest.php'; $suite->addTestSuite('CategorieTest'); + require_once dirname(__FILE__).'/AccountingAccountTest.php'; + $suite->addTestSuite('AccountingAccountTest'); + require_once dirname(__FILE__).'/RestAPIUserTest.php'; $suite->addTestSuite('RestAPIUserTest'); From 004c85b4ed2733a9626c4863353db51c21bedac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 11:35:37 +0200 Subject: [PATCH 171/183] Update journals_list.php --- htdocs/accountancy/admin/journals_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index f050b76e2d6..6d5baa59a11 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -613,7 +613,6 @@ if ($id) else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]}); - $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { $valuetoshow=$langs->trans($obj->label); From 24d353c9a75b80984c685e63d4c0020d0ad3b54c Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Thu, 10 May 2018 16:08:45 +0200 Subject: [PATCH 172/183] inversion of dateo and datee --- htdocs/fichinter/class/fichinter.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 4dee1f94f24..73e71b46398 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -369,8 +369,8 @@ class Fichinter extends CommonObject $this->statut = $obj->fk_statut; $this->duration = $obj->duree; $this->datec = $this->db->jdate($obj->datec); - $this->datee = $this->db->jdate($obj->dateo); - $this->dateo = $this->db->jdate($obj->datee); + $this->dateo = $this->db->jdate($obj->dateo); + $this->datee = $this->db->jdate($obj->datee); $this->datet = $this->db->jdate($obj->datet); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); From 05c2f206ff1ec9642022790b0cb49d79773a609a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2018 19:35:12 +0200 Subject: [PATCH 173/183] Fix missing lang --- htdocs/admin/company.php | 18 +++++++++--------- htdocs/core/class/commonobject.class.php | 3 ++- htdocs/langs/en_US/install.lang | 4 ++-- htdocs/langs/fr_FR/install.lang | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index dfa4b043978..ab5e3f103fd 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -75,9 +75,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'aZ09'),'chaine',0,'',$conf->entity); @@ -331,16 +331,16 @@ if ($action == 'edit' || $action == 'updateedit') // Addresse - print '
'; - print '
'; + print '
'; - print '
'; + print '
'; - print '
'; + print '
'; - $out.= $langs->trans("MailToSalaries"); + $out.= $langs->trans("MailToUsers"); $out.= ''; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time @@ -698,7 +698,7 @@ class FormMail extends Form if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $out.= '
'; - $out.= $langs->trans("MailToCCSalaries"); + $out.= $langs->trans("MailToCCUsers"); $out.= ''; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time @@ -1112,7 +1112,7 @@ class FormMail extends Form elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } - + $ret->label = 'default'; $ret->lang = $outputlangs->defaultlang; $ret->topic = ''; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index b155e2e4208..e80dd03b623 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -11,9 +11,9 @@ MailFrom=Sender MailErrorsTo=Errors to MailReply=Reply to MailTo=Receiver(s) -MailToSalaries=To salarie(s) +MailToUsers=To user(s) MailCC=Copy to -MailToCCSalaries=Copy to salarie(s) +MailToCCUsers=Copy to users(s) MailCCC=Cached copy to MailTopic=EMail topic MailText=Message From d072c2eb5db9344889e0112f27260b7e56645586 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 May 2018 23:09:27 +0200 Subject: [PATCH 181/183] Fix turnover invoiced by vat rate and country. Use fiscal month start. --- htdocs/compta/stats/byratecountry.php | 101 ++++++++++++++++++-------- 1 file changed, 72 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index b2186633413..33649dd51e0 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -1,9 +1,5 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2006-2007, 2015 Yannick Warnier - * Copyright (C) 2014 Ferran Marcet +/* Copyright (C) 2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +16,7 @@ */ /** - * \file htdocs/compta/tva/quadri_detail.php - * \ingroup tax + * \file htdocs/compta/stats/byratecountry.php * \brief VAT by rate */ @@ -240,15 +235,20 @@ print ''; print ''; print ''; print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +$i=0; +while($i < 12) +{ + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + print ''; + $i++; } print ''; $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; $sql .= " cc.label AS country,"; -for($i = 1; $i <= 12; $i ++) { +for ($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } $sql .= " SUM(fd.total_ht) as total"; @@ -271,31 +271,56 @@ dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - print ''; - if ($row[1] == 0) { + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql)) { + print ''; + if ($obj->product_type == 0) { print ''; } else { print ''; } - print ''; - - for($i = 3; $i <= 14; $i ++) { - print ''; + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; } - print ''; + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; print ''; } $db->free($resql); + + // Total + print ''; + print ''; + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + } + print ''; + print ''; + } else { print $db->lasterror(); // Show last sql error } + + print ''; print ''; print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +$i=0; +while($i < 12) +{ + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + print ''; + $i++; } print ''; @@ -326,22 +351,40 @@ dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); $resql2 = $db->query($sql2); if ($resql2) { $num = $db->num_rows($resql2); - - while ( $row = $db->fetch_row($resql2)) { - print ''; - if ($row[1] == 0) { + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql2)) { + print ''; + if ($obj->product_type == 0) { print ''; } else { print ''; } - print ''; - for($i = 3; $i <= 14; $i ++) { - print ''; + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; } - print ''; + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; print ''; } $db->free($resql2); + + // Total + print ''; + print ''; + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + } + print ''; + print ''; } else { print $db->lasterror(); // Show last sql error } From a1c799507a5058640952bc6473746e05bc4346e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 May 2018 08:16:24 +0200 Subject: [PATCH 182/183] Fix $contactobject not always defined --- htdocs/compta/facture/card.php | 156 +++++++++--------- .../doc/doc_generic_order_odt.modules.php | 2 +- .../doc/doc_generic_contract_odt.modules.php | 2 +- .../doc/doc_generic_invoice_odt.modules.php | 2 +- .../doc/doc_generic_product_odt.modules.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 2 +- .../doc/doc_generic_proposal_odt.modules.php | 2 +- .../doc/doc_generic_stock_odt.modules.php | 2 +- 8 files changed, 85 insertions(+), 85 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff3e7f3c407..476319fcdea 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -943,13 +943,13 @@ if (empty($reshook)) if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; } - - - - + + + + if($facture_source->type == Facture::TYPE_SITUATION) { - + if(!empty($facture_source->tab_previous_situation_invoice)) { // search the last invoice in cycle @@ -962,40 +962,40 @@ if (empty($reshook)) $searchPreviousInvoice=false; // find, exit; break; } - else + else { - $lineIndex--; // go to previous invoice in cycle + $lineIndex--; // go to previous invoice in cycle } } - - + + $maxPrevSituationPercent = 0; foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { if($prevLine->id == $line->fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); - + //$line->subprice = $line->subprice - $prevLine->subprice; $line->total_ht = $line->total_ht - $prevLine->total_ht; $line->total_tva = $line->total_tva - $prevLine->total_tva; $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - - + + } } - + // prorata $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - - + + } } @@ -1524,7 +1524,7 @@ if (empty($reshook)) $line->origin = $object->origin; $line->origin_id = $line->id; $line->fetch_optionals($line->id); - + // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { @@ -2201,12 +2201,12 @@ if (empty($reshook)) header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); } - - // Outing situation invoice from cycle + + // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer) { $object->fetch($id,'', '','', true); - + if ($object->statut == Facture::STATUS_VALIDATED && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer @@ -2214,20 +2214,20 @@ if (empty($reshook)) && $object->is_last_in_cycle() && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) - ) + ) { $outingError = 0; $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle if($newCycle > 1) { - // Search credit notes + // Search credit notes $lastCycle = $object->situation_cycle_ref; $lastSituationCounter = $object->situation_counter; $linkedCreditNotesList = array(); - + if (count($object->tab_next_situation_invoice) > 0) { foreach ($object->tab_next_situation_invoice as $next_invoice) { - if($next_invoice->type == Facture::TYPE_CREDIT_NOTE + if($next_invoice->type == Facture::TYPE_CREDIT_NOTE && $next_invoice->situation_counter == $object->situation_counter && $next_invoice->fk_facture_source == $object->id ) @@ -2236,7 +2236,7 @@ if (empty($reshook)) } } } - + $object->situation_cycle_ref = $newCycle; $object->situation_counter = 1; $object->situation_final = 0; @@ -2251,18 +2251,18 @@ if (empty($reshook)) $sql.= ' , situation_final=0'; $sql.= ' , situation_counter='.$object->situation_counter; $sql.= ' WHERE rowid IN ('.implode(',',$linkedCreditNotesList).')'; - + $resql=$db->query($sql); if (!$resql) $errors++; - + // Change each progression persent on each lines foreach($object->lines as $line) { - + // no traitement for special product if ($line->product_type == 9 ) continue; - - + + if(!empty($object->tab_previous_situation_invoice)) { // search the last invoice in cycle @@ -2280,8 +2280,8 @@ if (empty($reshook)) $lineIndex--; // go to previous invoice in cycle } } - - + + $maxPrevSituationPercent = 0; foreach($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { @@ -2290,19 +2290,19 @@ if (empty($reshook)) $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); } } - - + + $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - + if($line->update()<0) $errors++; - + } } } - + if (!$errors) { - setEventMessages($langs->trans('Updated')); + setEventMessages($langs->trans('Updated'), '', 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } else @@ -2310,7 +2310,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); } } - else + else { setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); } @@ -2331,7 +2331,7 @@ if (empty($reshook)) $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - + if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { if($fromElement == 'commande') @@ -2383,27 +2383,27 @@ if (empty($reshook)) $fk_prev_id = ''; $fk_unit = $originLine->fk_unit; $pu_ht_devise = $originLine->multicurrency_subprice; - + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); - + if($res > 0){ $importCount++; }else{ $error++; } } - else{ - $error++; + else{ + $error++; } } - + if($error) { setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors'); } } } - + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -3357,7 +3357,7 @@ else if ($id > 0 || ! empty($ref)) $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1); } } - + // Confirmation to remove invoice from cycle if ($action == 'situationout') { $text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref); @@ -3857,10 +3857,10 @@ else if ($id > 0 || ! empty($ref)) print ""; print ''; - - - + + + // Incoterms if (!empty($conf->incoterm->enabled)) @@ -4022,10 +4022,10 @@ else if ($id > 0 || ! empty($ref)) // List of previous situation invoices if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) { - + print '
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$row[2] . '' . price($row[$i]) . '' .$obj->country . '' . price($obj->$monthj) . '' . price($row[15]) . '' . price($obj->total) . '
' . price($totalpermonth[$j]) . '' . price($totalpermonth['total']) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $row[2] . '' . price($row[$i]) . '' . $obj->country . '' . price($obj->$monthj) . '' . price($row[15]) . '' . price($obj->total) . '
' . price($totalpermonth[$j]) . '' . price($totalpermonth['total']) . '
'; - - + + print ''; print ''; print ''; @@ -4035,14 +4035,14 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - - + + $total_prev_ht = $total_prev_ttc = 0; $total_global_ht = $total_global_ttc = 0; - + if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices - + $current_situation_counter = array(); foreach ($object->tab_previous_situation_invoice as $prev_invoice) { $totalpaye = $prev_invoice->getSommePaiement(); @@ -4060,8 +4060,8 @@ else if ($id > 0 || ! empty($ref)) print ''; } } - - + + $total_global_ht += $total_prev_ht ; $total_global_ttc += $total_prev_ttc ; $total_global_ht += $object->total_ht; @@ -4076,8 +4076,8 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - - + + print ''; print ''; print ''; print ''; print ''; - - + + if (count($object->tab_next_situation_invoice) > 0) { // List of next invoices /*print ''; @@ -4109,14 +4109,14 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print '';*/ - + $total_next_ht = $total_next_ttc = 0; - + foreach ($object->tab_next_situation_invoice as $next_invoice) { $totalpaye = $next_invoice->getSommePaiement(); $total_next_ht += $next_invoice->total_ht; $total_next_ttc += $next_invoice->total_ttc; - + print ''; print ''; print ''; @@ -4126,12 +4126,12 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + } - + $total_global_ht += $total_next_ht; $total_global_ttc += $total_next_ttc; - + print ''; print ''; if (! empty($conf->banque->enabled)) print ''; @@ -4140,7 +4140,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + print '
' . $langs->trans('ListOfSituationInvoices') . '' . $langs->trans('AmountTTC') . ' 
' . price($object->total_ttc) . '' . $object->getLibStatut(3, $object->getSommePaiement()) . '
' . $langs->trans('CurrentSituationTotal') . ''; @@ -4096,8 +4096,8 @@ else if ($id > 0 || ! empty($ref)) print '' . price($total_global_ttc) . ' 
' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
 
'; } @@ -4712,9 +4712,9 @@ else if ($id > 0 || ! empty($ref)) print ''; } else { print '
' . $langs->trans("CreateCreditNote") . '
'; - } + } } - + // remove situation from cycle if ($object->statut == Facture::STATUS_VALIDATED && $object->type == Facture::TYPE_SITUATION @@ -4730,12 +4730,12 @@ else if ($id > 0 || ! empty($ref)) { print ''; } - else + else { print ''; } } - + // Create next situation invoice if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { @@ -4804,16 +4804,16 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); - + $compatibleImportElementsList = false; - if($user->rights->facture->creer - && $object->statut == Facture::STATUS_DRAFT + if($user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) { $compatibleImportElementsList = array('commande','propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); - + // Show online payment link $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 8178af40c37..a7268ee0ea3 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -364,7 +364,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in order as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 98b644c8cce..99eb9feb2ea 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -304,7 +304,7 @@ class doc_generic_contract_odt extends ModelePDFContract $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in contract as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($substitutionarray, $outputlangs, $object); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 6d9d5172a7f..79741886119 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -372,7 +372,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in invoice as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 6c5fa8652f9..f63d62149eb 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -381,7 +381,7 @@ class doc_generic_product_odt extends ModelePDFProduct $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in product as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 5c0d025252e..35cbed4acf4 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -579,7 +579,7 @@ class doc_generic_project_odt extends ModelePDFProjects $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in project as contact_xxx tags $array_project_contact = array(); - if ($usecontact) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 0b71e9e862f..589d2d006c2 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -395,7 +395,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in proposal as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 0cadf3362d4..d7ceffaaf72 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -381,7 +381,7 @@ class doc_generic_stock_odt extends ModelePDFStock $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in stock as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); From f58e0d3bcfb5be14fa34d8da3d67480bfd017144 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 May 2018 08:24:20 +0200 Subject: [PATCH 183/183] Fix scrutinizer errors --- .../class/fournisseur.commande.class.php | 3 ++- .../fourn/class/fournisseur.facture.class.php | 3 ++- .../class/supplier_proposal.class.php | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index de09e800ede..7f74c02a115 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -573,9 +573,10 @@ class CommandeFournisseur extends CommonOrder */ function LibStatut($statut,$mode=0,$billed=0) { + global $conf, $langs; + if (empty($this->statuts) || empty($this->statutshort)) { - global $conf, $langs; $langs->load('orders'); $this->statuts[0] = 'StatusOrderDraft'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6b4c45eafad..b10be70dd40 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1521,8 +1521,9 @@ class FactureFournisseur extends CommonInvoice { $product_type = $prod->type; $label = $prod->label; + $fk_prod_fourn_price = 0; - // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // We use 'none' instead of $ref_supplier, because $ref_supplier may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc if ($result > 0) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 31a89ab332e..4b012e31c2d 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -72,7 +72,8 @@ class SupplierProposal extends CommonObject * @see user_author_id */ var $author; - var $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande + var $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande + var $ref_supplier; //Reference saisie lors de l'ajout d'une ligne à la demande var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (processed/billed) var $date; // Date of proposal var $date_livraison; @@ -350,7 +351,7 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Buying price without tax * @param string $label ??? * @param array $array_option extrafields array - * @param string $ref_fourn Supplier price reference + * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. * @param string $origin 'order', 'supplier_proposal', ... * @param int $origin_id Id of origin line @@ -359,7 +360,7 @@ class SupplierProposal extends CommonObject * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_fourn='', $fk_unit='', $origin='', $origin_id=0, $pu_ht_devise=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_supplier='', $fk_unit='', $origin='', $origin_id=0, $pu_ht_devise=0) { global $mysoc, $conf; @@ -409,6 +410,7 @@ class SupplierProposal extends CommonObject { $product_type = $prod->type; $label = $prod->label; + $fk_prod_fourn_price = $fk_fournprice; // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. @@ -532,7 +534,7 @@ class SupplierProposal extends CommonObject $this->line->fk_unit=$fk_unit; $this->line->origin=$origin; $this->line->origin_id=$origin_id; - $this->line->ref_fourn = $this->db->escape($ref_fourn); + $this->line->ref_fourn = $this->db->escape($ref_supplier); // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { @@ -616,11 +618,11 @@ class SupplierProposal extends CommonObject * @param string $label ??? * @param int $type 0/1=Product/service * @param array $array_option extrafields array - * @param string $ref_fourn Supplier price reference + * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $array_option=0, $ref_fourn='', $fk_unit='') + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $array_option=0, $ref_supplier='', $fk_unit='') { global $conf,$user,$langs, $mysoc; @@ -706,7 +708,7 @@ class SupplierProposal extends CommonObject $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; - $this->line->ref_fourn = $ref_fourn; + $this->line->ref_fourn = $ref_supplier; $this->line->fk_unit = $fk_unit; // infos marge @@ -2730,7 +2732,8 @@ class SupplierProposalLine extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines - var $ref_fourn; + var $ref_fourn; + var $ref_supplier; // Multicurrency var $fk_multicurrency;