From f91fe41f45e14c673917eb40ece77e04b46f3525 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 19 Mar 2018 15:50:56 +0100 Subject: [PATCH 01/31] 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 02/31] 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 03/31] 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 04/31] 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 05/31] 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 06/31] 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 07/31] 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 08/31] 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 09/31] 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 10/31] 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 11/31] 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 12/31] 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 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 13/31] 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 14/31] 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 ''; print ''; print ''; + } + if (! empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + 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 ''; } 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 ''.$objp->label.''; + } + if (! empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + print ''.$objp->type_mouvement.''; } 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 ce40a51bdb15ce44f78c91504ef73f017eca2196 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Thu, 10 May 2018 16:08:45 +0200 Subject: [PATCH 15/31] 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 6b2dfa052811f8cad3059acb3dd9bc3966c2db23 Mon Sep 17 00:00:00 2001 From: atm-john Date: Thu, 10 May 2018 21:06:18 +0200 Subject: [PATCH 16/31] 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'; ?> - 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'); ?> 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 17/31] 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 ''."\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 '
'.$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 '
'.$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 18/31] 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 '
'.$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 19/31] 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 20/31] 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 cb815e5e3b9f23a9d01106cb5953eaf08a5382d2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 May 2018 07:50:24 +0200 Subject: [PATCH 21/31] 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 9b2f62791b2c3bcb8a735b2cde39e4b381e97b6a Mon Sep 17 00:00:00 2001 From: Chl Date: Sun, 13 May 2018 15:43:17 +0200 Subject: [PATCH 22/31] 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 675ae97f997b2c161b12d7e6811f10e98ee149dc Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 May 2018 21:52:11 +0200 Subject: [PATCH 23/31] 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 f773317bf5c7061bf84a6e66a1d83583278e2149 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 May 2018 15:55:42 +0200 Subject: [PATCH 24/31] 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("FoundCats").'
'.$langs->trans("Size").'
'; - 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 25/31] 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 26/31] 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 27/31] 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 933e277862d63ed87728b0f45978b4d25789f3aa Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Wed, 16 May 2018 19:56:01 +0100 Subject: [PATCH 28/31] 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 29/31] 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 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 30/31] 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 004c85b4ed2733a9626c4863353db51c21bedac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 May 2018 11:35:37 +0200 Subject: [PATCH 31/31] 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);