From 288a876491ec67529bc0166ba266ec345fa18234 Mon Sep 17 00:00:00 2001 From: Dan Rusu Date: Mon, 11 Feb 2019 09:14:06 +0200 Subject: [PATCH 01/30] add API method to create credit note from invoice --- .../facture/class/api_invoices.class.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 555b6179677..0fb203f50d1 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -839,6 +839,118 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } + /** + * Make credt note from invoice + * + * @param int $id Invoice ID + * @url POST {id}/makecreditnote + * + * @return array An invoice object + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + */ + function makecreditnote($id) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + + $this->db->begin(); + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->fetch_thirdparty(); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + if (! $object->paye) // protection against multiple submit + { + $this->invoice->fetch_lines(); + + // Boucle sur chaque taux de tva + $i=0; + foreach($this->invoice->lines as $line) + { + $amount_ht[$line->tva_tx]+=$line->total_ht; + $amount_tva[$line->tva_tx]+=$line->total_tva; + $amount_ttc[$line->tva_tx]+=$line->total_ttc; + $i++; + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($this->db); + if ($this->invoice->type == 2) $discount->description='(CREDIT_NOTE)'; + elseif ($this->invoice->type == 3) $discount->description='(DEPOSIT)'; + else { + $this->error="CantConvertToReducAnInvoiceOfThisType"; + return -1; + } + $discount->tva_tx=abs($this->invoice->total_ttc); + $discount->fk_soc=$this->invoice->socid; + $discount->fk_facture_source=$this->invoice->id; + + $error=0; + foreach($amount_ht as $tva_tx => $xxx) + { + $discount->amount_ht=abs($amount_ht[$tva_tx]); + $discount->amount_tva=abs($amount_tva[$tva_tx]); + $discount->amount_ttc=abs($amount_ttc[$tva_tx]); + $discount->tva_tx=abs($tva_tx); + + $result=$discount->create(DolibarrApiAccess::$user); + if ($result < 0) + { + $error++; + break; + } + } + + if (! $error) + { + // Classe facture + $result=$this->invoice->set_paid(DolibarrApiAccess::$user); + if ($result > 0) + { + //$mesg='OK'.$discount->id; + $this->db->commit(); + } + else + { + throw new RestException(500, 'Could not set paid'); + $this->db->rollback(); + } + } + else + { + throw new RestException(500, 'Discount error'); + $this->db->rollback(); + } + } + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->invoice); + } + /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount * From 0698ddbd7779a6eec7c546c470d63c8c65e6d1cc Mon Sep 17 00:00:00 2001 From: Dan Rusu Date: Mon, 11 Feb 2019 09:24:16 +0200 Subject: [PATCH 02/30] Revert "add API method to create credit note from invoice" This reverts commit 288a876491ec67529bc0166ba266ec345fa18234. --- .../facture/class/api_invoices.class.php | 112 ------------------ 1 file changed, 112 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 0fb203f50d1..555b6179677 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -839,118 +839,6 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } - /** - * Make credt note from invoice - * - * @param int $id Invoice ID - * @url POST {id}/makecreditnote - * - * @return array An invoice object - * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 - */ - function makecreditnote($id) - { - if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - - $this->db->begin(); - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->invoice->fetch_thirdparty(); - if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); - } - - if (! $object->paye) // protection against multiple submit - { - $this->invoice->fetch_lines(); - - // Boucle sur chaque taux de tva - $i=0; - foreach($this->invoice->lines as $line) - { - $amount_ht[$line->tva_tx]+=$line->total_ht; - $amount_tva[$line->tva_tx]+=$line->total_tva; - $amount_ttc[$line->tva_tx]+=$line->total_ttc; - $i++; - } - - // Insert one discount by VAT rate category - $discount = new DiscountAbsolute($this->db); - if ($this->invoice->type == 2) $discount->description='(CREDIT_NOTE)'; - elseif ($this->invoice->type == 3) $discount->description='(DEPOSIT)'; - else { - $this->error="CantConvertToReducAnInvoiceOfThisType"; - return -1; - } - $discount->tva_tx=abs($this->invoice->total_ttc); - $discount->fk_soc=$this->invoice->socid; - $discount->fk_facture_source=$this->invoice->id; - - $error=0; - foreach($amount_ht as $tva_tx => $xxx) - { - $discount->amount_ht=abs($amount_ht[$tva_tx]); - $discount->amount_tva=abs($amount_tva[$tva_tx]); - $discount->amount_ttc=abs($amount_ttc[$tva_tx]); - $discount->tva_tx=abs($tva_tx); - - $result=$discount->create(DolibarrApiAccess::$user); - if ($result < 0) - { - $error++; - break; - } - } - - if (! $error) - { - // Classe facture - $result=$this->invoice->set_paid(DolibarrApiAccess::$user); - if ($result > 0) - { - //$mesg='OK'.$discount->id; - $this->db->commit(); - } - else - { - throw new RestException(500, 'Could not set paid'); - $this->db->rollback(); - } - } - else - { - throw new RestException(500, 'Discount error'); - $this->db->rollback(); - } - } - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->_cleanObjectDatas($this->invoice); - } - /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount * From 9ce4b91f5d17e07617abe5c818f7b49289b39fa2 Mon Sep 17 00:00:00 2001 From: Dan Rusu Date: Mon, 11 Feb 2019 09:31:43 +0200 Subject: [PATCH 03/30] NEW | make credit note from invoice inspired from the action of the button "Make credit note" from UI. - load invoice data and lines - check invoice type - calculate totals and create new credit notes - create DiscountAbsolute & commit changes --- .../facture/class/api_invoices.class.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 555b6179677..dede6f735c6 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -839,6 +839,118 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } + /** + * Make credt note from invoice + * + * @param int $id Invoice ID + * @url POST {id}/makecreditnote + * + * @return array An invoice object + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + */ + function makecreditnote($id) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + + $this->db->begin(); + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->fetch_thirdparty(); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + if (! $object->paye) // protection against multiple submit + { + $this->invoice->fetch_lines(); + + // Boucle sur chaque taux de tva + $i=0; + foreach($this->invoice->lines as $line) + { + $amount_ht[$line->tva_tx]+=$line->total_ht; + $amount_tva[$line->tva_tx]+=$line->total_tva; + $amount_ttc[$line->tva_tx]+=$line->total_ttc; + $i++; + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($this->db); + if ($this->invoice->type == 2) $discount->description='(CREDIT_NOTE)'; + elseif ($this->invoice->type == 3) $discount->description='(DEPOSIT)'; + else { + $this->error="CantConvertToReducAnInvoiceOfThisType"; + return -1; + } + $discount->tva_tx=abs($this->invoice->total_ttc); + $discount->fk_soc=$this->invoice->socid; + $discount->fk_facture_source=$this->invoice->id; + + $error=0; + foreach($amount_ht as $tva_tx => $xxx) + { + $discount->amount_ht=abs($amount_ht[$tva_tx]); + $discount->amount_tva=abs($amount_tva[$tva_tx]); + $discount->amount_ttc=abs($amount_ttc[$tva_tx]); + $discount->tva_tx=abs($tva_tx); + + $result=$discount->create(DolibarrApiAccess::$user); + if ($result < 0) + { + $error++; + break; + } + } + + if (! $error) + { + // Classe facture + $result=$this->invoice->set_paid(DolibarrApiAccess::$user); + if ($result > 0) + { + //$mesg='OK'.$discount->id; + $this->db->commit(); + } + else + { + throw new RestException(500, 'Could not set paid'); + $this->db->rollback(); + } + } + else + { + throw new RestException(500, 'Discount error'); + $this->db->rollback(); + } + } + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->invoice); + } + /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount * From 57e2971a22ad350b96e2a1bc8f303d909e9d7d41 Mon Sep 17 00:00:00 2001 From: Dan Rusu Date: Mon, 11 Feb 2019 19:58:01 +0200 Subject: [PATCH 04/30] fix code indent --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index dede6f735c6..8fbfa34bce9 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -866,7 +866,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -944,7 +944,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From 2c5956907400e0d2c5c57e4481fd00f62696c60a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:02:07 +0100 Subject: [PATCH 05/30] update with html5 compliant code --- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 7dab385681a..d63df9f87b9 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -51,7 +51,7 @@ foreach($linkedObjectBlock as $key => $objectlink) getNomUrl(1); ?> date_contrat, 'day'); ?> - $objectlink) } echo price($totalcontrat); } ?> - getLibStatut(7); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + getLibStatut(7); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> From 5b7294e9e18b2f221b19d9da24ec7dcae43a0e16 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:06:25 +0100 Subject: [PATCH 06/30] update with html5 compliant code --- htdocs/contrat/card.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 40242ee8068..799c06564df 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1563,14 +1563,14 @@ else print ''; print ''.$langs->trans("ServiceNb", $cursorline).''; print ''.$langs->trans("VAT").''; - print ''.$langs->trans("PriceUHT").''; + print ''.$langs->trans("PriceUHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("PriceUHTCurrency").''; + print ''.$langs->trans("PriceUHTCurrency").''; } print ''.$langs->trans("Qty").''; - if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans("Unit").''; - print ''.$langs->trans("ReductionShort").''; - if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''.$langs->trans("BuyingPrice").''; + if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans("Unit").''; + print ''.$langs->trans("ReductionShort").''; + if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''.$langs->trans("BuyingPrice").''; print ' '; print "\n"; @@ -1618,10 +1618,10 @@ else print vatrate($objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), '%', $objp->info_bits); print ''; // Price - print ''.($objp->subprice != '' ? price($objp->subprice) : '')."\n"; + print ''.($objp->subprice != '' ? price($objp->subprice) : '')."\n"; // Price multicurrency if (!empty($conf->multicurrency->enabled)) { - print ''.price($objp->multicurrency_subprice).''; + print ''.price($objp->multicurrency_subprice).''; } // Quantite print ''.$objp->qty.''; @@ -1630,7 +1630,7 @@ else // Remise if ($objp->remise_percent > 0) { - print ''.$objp->remise_percent."%\n"; + print ''.$objp->remise_percent."%\n"; } else { @@ -1641,7 +1641,7 @@ else if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''.price($objp->pa_ht).''; // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) - print ''; + print ''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; @@ -1746,10 +1746,10 @@ else $doleditor->Create(); print ''; - print ''; + print ''; print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); print ''; - print ''; + print ''; print ''; if ($conf->global->PRODUCT_USE_UNITS) { @@ -1757,10 +1757,10 @@ else print $form->selectUnits($objp->fk_unit, "unit"); print ''; } - print '%'; + print '%'; if (! empty($usemargins)) { - print ''; + print ''; if ($objp->fk_product) print ''; print ''; } @@ -1880,7 +1880,7 @@ else print ''; print ''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''; - print ''; + print ''; if ($user->societe_id == 0) { if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') From f24356ae10b646a892112f4de9877ea5e99fa5cb Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:08:35 +0100 Subject: [PATCH 07/30] update with html5 compliant code --- htdocs/contrat/index.php | 24 ++++++++++++------------ htdocs/contrat/list.php | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index dfcb1e8457c..05135f39aeb 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -189,7 +189,7 @@ foreach($listofstatus as $status) print ''; print ''.$staticcontratligne->LibStatut($status, 0, ($bool?1:0)).''; - print ''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).''; + print ''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).''; print "\n"; } if ($status==4 && ! $bool) $bool=true; @@ -218,15 +218,15 @@ foreach($listofstatus as $status) { print ''; print ''.$staticcontratligne->LibStatut($status, 0, ($bool?1:0)).''; - print ''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).''; + print ''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).''; if ($status==4 && ! $bool) $bool=true; else $bool=false; print "\n"; } } //if ($totalinprocess != $total) -//print ''.$langs->trans("Total").' ('.$langs->trans("ServicesRunning").')'.$totalinprocess.''; -print ''.$langs->trans("Total").''.$total.''; +//print ''.$langs->trans("Total").' ('.$langs->trans("ServicesRunning").')'.$totalinprocess.''; +print ''.$langs->trans("Total").''.$total.''; print "
"; @@ -332,7 +332,7 @@ if ($result) print ''.$langs->trans("LastContracts", 5).''; print ''.$langs->trans("DateModification").''; - //print ''.$langs->trans("Status").''; + //print ''.$langs->trans("Status").''; print ''.$langs->trans("Services").''; print "\n"; @@ -354,10 +354,10 @@ if ($result) print ''; print ''.dol_print_date($db->jdate($obj->tms), 'dayhour').''; //print ''.$staticcontrat->LibStatut($obj->statut,2).''; - print ''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3):'').''; - print ''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0):'').''; - print ''.($obj->nb_expired>0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4, 3, 1):'').''; - print ''.($obj->nb_closed>0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5, 3):'').''; + print ''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3):'').''; + print ''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0):'').''; + print ''.($obj->nb_expired>0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4, 3, 1):'').''; + print ''.($obj->nb_closed>0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5, 3):'').''; print "\n"; $i++; } @@ -432,7 +432,7 @@ if ($resql) $staticcompany->name=$obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''; + print ''; $dateend=$db->jdate($obj->date_fin_validite); print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)?1:0); print ''; @@ -511,7 +511,7 @@ if ($resql) $staticcompany->name=$obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''; + print ''; print $staticcontratligne->LibStatut($obj->statut, 3); print ''; print "\n"; @@ -590,7 +590,7 @@ if ($resql) $staticcompany->name=$obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''; + print ''; print $staticcontratligne->LibStatut($obj->statut, 3, 1); print ''; print "\n"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 24dccaae25d..fb2422b7762 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -559,7 +559,7 @@ if (! empty($arrayfields['lower_planned_end_date']['checked'])) // Status if (! empty($arrayfields['status']['checked'])) { - print ''; + print ''; } print ''; $searchpicto=$form->showFilterButtons(); From 3a2b5e28c4ef7fa6944498968aa8bcc81822d2a5 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:17:11 +0100 Subject: [PATCH 08/30] update with html5 compliant code --- htdocs/contrat/services_list.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 68f8595c294..f2d827b87cb 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -394,7 +394,7 @@ $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // N print $hookmanager->resPrint; if (! empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['cd.tms']['checked'])) print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -511,7 +511,7 @@ if (! empty($arrayfields['cd.tms']['checked'])) if (! empty($arrayfields['status']['checked'])) { // Status - print ''; + print ''; $arrayofstatus=array( '0'=>$langs->trans("ServiceStatusInitial"), '4'=>$langs->trans("ServiceStatusRunning"), @@ -523,7 +523,7 @@ if (! empty($arrayfields['status']['checked'])) print ''; } // Action column -print ''; +print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; @@ -589,7 +589,7 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['cd.total_ht']['checked'])) { - print ''; + print ''; print price($obj->total_ht); print ''; $totalarray['totalht'] += $obj->total_ht; @@ -601,7 +601,7 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['cd.total_tva']['checked'])) { - print ''; + print ''; print price($obj->total_tva); print ''; $totalarray['totalvat'] += $obj->total_tva; @@ -613,14 +613,14 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['cd.tva_tx']['checked'])) { - print ''; + print ''; print price2num($obj->tva_tx).'%'; print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['cd.subprice']['checked'])) { - print ''; + print ''; print price($obj->subprice); print ''; if (! $i) $totalarray['nbfield']++; @@ -698,7 +698,7 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['status']['checked'])) { - print ''; + print ''; if ($obj->cstatut == 0) // If contract is draft, we say line is also draft { print $contractstatic->LibStatut(0, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)); @@ -735,9 +735,9 @@ if (isset($totalarray['displaytotalline'])) { if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; } - elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; - elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; - elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; + elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; + elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; + elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; else print ''; } print ''; From 047ec90d78fd32f6348c73aabb14d4c0b091b972 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:38:14 +0100 Subject: [PATCH 09/30] update with html5 compliant code --- htdocs/core/ajax/ajaxdirtree.php | 10 ++--- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/class/html.formmargin.class.php | 42 ++++++++++----------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 1e5e31b4385..46a5e0e6d7d 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -425,7 +425,7 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, print '';*/ // Nb of docs - print ''; + print ''; print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; print ''; print ''; @@ -433,19 +433,19 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, print ''; // Edit link - print ''.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').''; // Add link - //print ''.img_edit_add().''; - //print ' '; + //print ''.img_edit_add().''; + //print ' '; // Info if ($modulepart == 'ecm') { - print ''; + print ''; $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
'; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 752d2406ea4..f983565250b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -455,7 +455,7 @@ class FormMail extends Form } if (! empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. { - $out.= ''; + $out.= ''; //$out.='
'; if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // New usage diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index cce12ae5f8b..5aecb6efc71 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -223,16 +223,16 @@ class FormMargin print ''; print ''; print ''; - print ''; + print ''; if ($conf->global->MARGIN_TYPE == "1") - print ''; + print ''; else - print ''; - print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; if (! empty($conf->product->enabled)) @@ -240,13 +240,13 @@ class FormMargin //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } @@ -254,13 +254,13 @@ class FormMargin { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } @@ -268,13 +268,13 @@ class FormMargin { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } print '
'.$langs->trans('Margins').''.$langs->trans('SellingPrice').''.$langs->trans('SellingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('MarginRate').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').''.$langs->trans('MarkRate').'
'.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'
'.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'
'.$langs->trans('TotalMargin').''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'
'; From d83b77432d1c158cddd51232df597841910f555f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 19 Feb 2019 17:42:12 +0100 Subject: [PATCH 10/30] update with html5 compliant code --- .../browser/default/frmresourceslist.php | 2 +- htdocs/core/lib/admin.lib.php | 6 +++--- htdocs/core/lib/agenda.lib.php | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php b/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php index f7df05acdde..81f536f5228 100644 --- a/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php +++ b/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php @@ -101,7 +101,7 @@ oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize ) sLink + fileName + '<\/a>' + - '<\/td> ' + + '<\/td> ' + fileSize + ' KB' + '<\/td><\/tr>' ; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index b58c9107cf8..004762d2810 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -367,7 +367,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle $listofinsertedrowid[$cursorinsert]=$insertedrowid; dol_syslog('Admin.lib::run_sql Insert nb '.$cursorinsert.', done in table '.$table.', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG); } - // print 'OK'; + // print 'OK'; } else { @@ -410,13 +410,13 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($error == 0) { if (! $silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (! $silent) print ''.$langs->trans("OK").''."\n"; + if (! $silent) print ''.$langs->trans("OK").''."\n"; $ok = 1; } else { if (! $silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (! $silent) print ''.$langs->trans("KO").''."\n"; + if (! $silent) print ''.$langs->trans("KO").''."\n"; $ok = 0; } diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index c24cc0928ed..531b90b75e3 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -239,7 +239,7 @@ function show_array_actions_to_do($max = 5) print ''; print ''; - print ''; + print ''; print ''; $var = true; @@ -276,7 +276,7 @@ function show_array_actions_to_do($max = 5) $datep2=$db->jdate($obj->dp2); // Date - print '"; // Statut - print "\n"; + print '\n"; print "\n"; @@ -336,7 +336,7 @@ function show_array_last_actions_done($max = 5) print '
'.$langs->trans("LastActionsToDo", $max).''.$langs->trans("FullList").''.$langs->trans("FullList").'
'.dol_print_date($datep, 'day').' '; + print ''.dol_print_date($datep, 'day').' '; $late=0; if ($obj->percent == 0 && $datep && $datep < time()) $late=1; if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; @@ -286,7 +286,7 @@ function show_array_actions_to_do($max = 5) print "".$staticaction->LibStatut($obj->percent, 3)."'.$staticaction->LibStatut($obj->percent, 3)."
'; print ''; - print ''; + print ''; print ''; $var = true; $i = 0; @@ -369,11 +369,11 @@ function show_array_last_actions_done($max = 5) print ''; // Date - print '"; // Statut - print "\n"; + print "\n"; print "\n"; $i++; From 7128270a950d0af9d310384daa8a849be688cd4b Mon Sep 17 00:00:00 2001 From: Cristian Torres Date: Tue, 19 Feb 2019 11:37:46 -0600 Subject: [PATCH 11/30] [FIX] Variable $i is already declared It was preventing displaying of the other accounts --- htdocs/compta/resultat/clientfourn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index fef607ac0dd..f0a01d1ae04 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -301,7 +301,7 @@ if ($modecompta == 'BOOKKEEPING') // Get cpts of category/group $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere); - foreach($cpts as $i => $cpt) + foreach($cpts as $j => $cpt) { $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cpt['dc']); if ($return < 0) { From 33164bcb3ec423b747c92d814245cd1808c32724 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Feb 2019 14:25:09 +0100 Subject: [PATCH 12/30] fix : When comparing two booleans, it is generally considered safer to use the strict comparison operator. --- htdocs/accountancy/customer/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 873018cf6c9..6a7d59a46ce 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -456,7 +456,7 @@ if ($result) { if ($objp->country_sell == '1') { $objp->code_sell_p = $objp->code_sell; $objp->aarowid_suggest = $objp->aarowid; - } elseif ($isinEEC == true) { + } elseif ($isinEEC === true) { $objp->code_sell_p = $objp->code_sell_intra; $objp->aarowid_suggest = $objp->aarowid_intra; } else { From 5a889300624a82a8a68365fca064e8f4a2c0cf7e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Feb 2019 14:38:12 +0100 Subject: [PATCH 13/30] fix : The property total_vat does not exist on Reception --- .../modules/reception/doc/doc_generic_reception_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index fb93998ef84..bcae2c990af 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -300,7 +300,7 @@ class doc_generic_reception_odt extends ModelePdfReception '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook From 54da44b5065c81b92ba8dbf7f817e480f9535e9a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Feb 2019 19:50:03 +0100 Subject: [PATCH 14/30] Translation --- htdocs/core/class/html.formcompany.class.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index c60b6675a1d..f92bee4519f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -188,11 +188,10 @@ class FormCompany // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. - * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. - * La cle de la liste est le code (il peut y avoir plusieurs entree pour - * un code donnee mais dans ce cas, le champ pays differe). - * Ainsi les liens avec les departements se font sur un departement independemment de son nom. + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. * * @param string $selected Code state preselected * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show @@ -207,11 +206,10 @@ class FormCompany // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. - * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. - * La cle de la liste est le code (il peut y avoir plusieurs entree pour - * un code donnee mais dans ce cas, le champ pays differe). - * Ainsi les liens avec les departements se font sur un departement independemment de son nom. + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. * * @param string $selected Code state preselected (mus be state id) * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show From 7360e1c0d45a032b8d6f77ea2cb76c93b5214b0d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:19:21 +0100 Subject: [PATCH 15/30] Fix servicestatus list of payment stripe --- htdocs/stripe/payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index bf8802f4c89..f9599984fd0 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -85,7 +85,7 @@ if (! empty($conf->stripe->enabled)) if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; - $servicestatus = 0; + $servicestatus = 1; } $stripe=new Stripe($db); From 5021252622ca321979c6ef39d0b70e75b49b55df Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:23:28 +0100 Subject: [PATCH 16/30] Fix stripe payment list of transaction --- htdocs/stripe/transaction.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 467d242a0c8..9620e3399c9 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -60,19 +60,20 @@ $stripe = new Stripe($db); llxHeader('', $langs->trans("StripeTransactionList")); -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +if (! empty($conf->stripe->enabled)) { $service = 'StripeTest'; - $servicestatus = '0'; - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); -} -else -{ - $service = 'StripeLive'; - $servicestatus = '1'; + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } + + $stripe=new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) } -$stripeacc = $stripe->getStripeAccount($service); /*if (empty($stripeaccount)) { print $langs->trans('ErrorStripeAccountNotDefined'); From 232741d9198ba3525f4900ecca605c32948b5568 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:27:50 +0100 Subject: [PATCH 17/30] Update payment.php --- htdocs/stripe/payment.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index f9599984fd0..fd1b9fcc84b 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -78,19 +78,22 @@ if ($facid > 0) $ret=$object->fetch($facid); } -if (! empty($conf->stripe->enabled)) +if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; - $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } - - $stripe=new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) + $servicestatus = '0'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } +else +{ + $service = 'StripeLive'; + $servicestatus = '1'; +} +$stripeacc = $stripe->getStripeAccount($service); +/*if (empty($stripeaccount)) +{ + print $langs->trans('ErrorStripeAccountNotDefined'); +}*/ // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('paiementcard','globalcard')); From 3416d2bdd1a04b488ddba549609c9419e5cb6675 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:29:38 +0100 Subject: [PATCH 18/30] Update transaction.php --- htdocs/stripe/transaction.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 9620e3399c9..b0575a53ee4 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -60,20 +60,18 @@ $stripe = new Stripe($db); llxHeader('', $langs->trans("StripeTransactionList")); -if (! empty($conf->stripe->enabled)) +if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; - $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } - - $stripe=new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) + $servicestatus = '0'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } - +else +{ + $service = 'StripeLive'; + $servicestatus = '1'; +} +$stripeacc = $stripe->getStripeAccount($service); /*if (empty($stripeaccount)) { print $langs->trans('ErrorStripeAccountNotDefined'); From f027bd2b08b53bd4a67da0aa4043e44b189d8927 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:30:25 +0100 Subject: [PATCH 19/30] Update payment.php --- htdocs/stripe/payment.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index fd1b9fcc84b..bb6a6f1dbb2 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -8,7 +8,7 @@ * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2018 Thibault FOUCART + * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -98,7 +98,6 @@ $stripeacc = $stripe->getStripeAccount($service); // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('paiementcard','globalcard')); - /* * Actions */ From 454ab2e866d23d875d6db6419ef0b60549e4d2a7 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:54:26 +0100 Subject: [PATCH 20/30] FIX Stripe live Oauth --- htdocs/admin/oauthlogintokens.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index aa0dd0978d9..e284d4b4834 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -154,6 +154,13 @@ if ($mode == 'setup' && $user->admin) $urltodelete=''; $urltocheckperms=''; } + elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') + { + $OAUTH_SERVICENAME='StripeLive'; + $urltorenew=$urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete=''; + $urltocheckperms=''; + } else { $urltorenew=''; From dd160a62425b11032736fa16798f6e6f4761b726 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Feb 2019 14:56:39 +0100 Subject: [PATCH 21/30] Create stripelive_oauthcallback.php --- .../oauth/stripelive_oauthcallback.php | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 htdocs/core/modules/oauth/stripelive_oauthcallback.php diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php new file mode 100644 index 00000000000..cf2c2418092 --- /dev/null +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -0,0 +1,179 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/modules/oauth/stripe_oauthcallback.php + * \ingroup oauth + * \brief Page to get oauth callback + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; +use OAuth\Common\Storage\DoliStorage; +use OAuth\Common\Consumer\Credentials; +use OAuth\OAuth2\Service\GitHub; + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + + +$action = GETPOST('action', 'alpha'); +$backtourl = GETPOST('backtourl', 'alpha'); + + +/** + * Create a new instance of the URI class with the current URI, stripping the query string + */ +$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); +//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); +//$currentUri->setQuery(''); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripe_oauthcallback.php'); + + +/** + * Load the credential for the service + */ + +/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */ +$serviceFactory = new \OAuth\ServiceFactory(); +$httpClient = new \OAuth\Common\Http\Client\CurlClient(); +// TODO Set options for proxy and timeout +// $params=array('CURLXXX'=>value, ...) +//$httpClient->setCurlParameters($params); +$serviceFactory->setHttpClient($httpClient); + +// Dolibarr storage +$storage = new DoliStorage($db, $conf); + +// Setup the credentials for the requests +$credentials = new Credentials( + $conf->global->OAUTH_STRIPE_TEST_ID, + $conf->global->STRIPE_LIVE_SECRET_KEY, + $currentUri->getAbsoluteUri() +); + +$requestedpermissionsarray=array(); +if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back +/*if ($action != 'delete' && empty($requestedpermissionsarray)) +{ + print 'Error, parameter state is not defined'; + exit; +}*/ +//var_dump($requestedpermissionsarray);exit; + +// Instantiate the Api service using the credentials, http client and storage mechanism for the token +/** @var $apiService Service */ +//$apiService = $serviceFactory->createService('StripeTest', $credentials, $storage, $requestedpermissionsarray); + +$sql="INSERT INTO ".MAIN_DB_PREFIX."oauth_token set service='StripeLive', entity=".$conf->entity; +$db->query($sql); + +// access type needed to have oauth provider refreshing token +//$apiService->setAccessType('offline'); + +$langs->load("oauth"); + + +/* + * Actions + */ + + +if ($action == 'delete') +{ + $storage->clearToken('StripeLive'); + + setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + + header('Location: ' . $backtourl); + exit(); +} + +if (! empty($_GET['code'])) // We are coming from oauth provider page +{ + // We should have + //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) + + dol_syslog("We are coming from the oauth provider page"); + //llxHeader('',$langs->trans("OAuthSetup")); + + //$linkback=''.$langs->trans("BackToModuleList").''; + //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); + + //dol_fiche_head(); + // retrieve the CSRF state parameter + $state = isset($_GET['state']) ? $_GET['state'] : null; + //print '
'.$langs->trans("LastDoneTasks", $max).''.$langs->trans("FullList").''.$langs->trans("FullList").'
'.dol_print_date($db->jdate($obj->da2), 'day'); + print ''.dol_print_date($db->jdate($obj->da2), 'day'); print "".$staticaction->LibStatut($obj->percent, 3)."".$staticaction->LibStatut($obj->percent, 3)."
'; + + // This was a callback request from service, get the token + try { + //var_dump($_GET['code']); + //var_dump($state); + //var_dump($apiService); // OAuth\OAuth2\Service\GitHub + + //$token = $apiService->requestAccessToken($_GET['code'], $state); + $token = $apiService->requestAccessToken($_GET['code']); + // Github is a service that does not need state to be stored. + // Into constructor of GitHub, the call + // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri) + // has not the ending parameter to true like the Google class constructor. + + setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token + + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + header('Location: ' . $backtourl); + exit(); + } catch (Exception $e) { + print $e->getMessage(); + } +} +else // If entry on page with no parameter, we arrive here +{ + $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + + // This may create record into oauth_state before the header redirect. + // Creation of record with state in this tables depend on the Provider used (see its constructor). + if (GETPOST('state')) + { + $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); + } + else + { + //$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated + //https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write + $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->OAUTH_STRIPE_LIVE_ID.'&scope=read_write'; + } + + // we go on oauth provider authorization page + header('Location: ' . $url); + exit(); +} + + +/* + * View + */ + +// No view at all, just actions + +$db->close(); From f7c0044e6004ab47c349092b398b4b633482b83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 09:33:21 +0100 Subject: [PATCH 22/30] doc comment --- htdocs/core/class/html.formfile.class.php | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 49ecd40b4e8..6e7914d9206 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1550,20 +1550,20 @@ class FormFile // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices - if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'supplier_proposal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'product') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - if ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - if ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - if ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} - if ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - if ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} + elseif ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices + elseif ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'supplier_proposal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'product') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} + elseif ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} + elseif ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} + elseif ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} + elseif ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} if (! $id && ! $ref) continue; $found=0; @@ -1720,7 +1720,7 @@ class FormFile print '
'; print ''; -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Links"), $_SERVER['PHP_SELF'], "name", @@ -1730,7 +1730,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( "", "", "", @@ -1738,7 +1738,7 @@ print_liste_field_titre( "", 'class="right"' ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Date"), $_SERVER['PHP_SELF'], "date", @@ -1748,7 +1748,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( '', $_SERVER['PHP_SELF'], "", @@ -1825,7 +1825,7 @@ print_liste_field_titre( * @param array $file Array with data of file. Example: array('name'=>...) * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs - * @param string $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file) + * @param integer $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file) * @param string $param More param on http links * @return string $out Output string with HTML */ From 6ee29559f9beeafd066b02d479da96b018f4e6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 09:44:45 +0100 Subject: [PATCH 23/30] doc comment entrepot.class.php --- htdocs/product/stock/class/entrepot.class.php | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index a872bdae8ae..81e8680034e 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2008 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2016 Francis Appels + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,8 +77,14 @@ class Entrepot extends CommonObject */ public $address; - //! Code Postal + /** + * @var string Zipcode + */ public $zip; + + /** + * @var string Town + */ public $town; /** @@ -573,26 +580,26 @@ class Entrepot extends CommonObject { return $label; } - if ($mode == 1) + elseif ($mode == 1) { return $label; } - if ($mode == 2) + elseif ($mode == 2) { if ($statut > 0) $picto = 'statut4'; return img_picto($label, $picto).' '.$label; } - if ($mode == 3) + elseif ($mode == 3) { if ($statut > 0) $picto = 'statut4'; return img_picto($label, $picto).' '.$label; } - if ($mode == 4) + elseif ($mode == 4) { if ($statut > 0) $picto = 'statut4'; return img_picto($label, $picto).' '.$label; } - if ($mode == 5) + elseif ($mode == 5) { if ($statut > 0) $picto = 'statut4'; return $label.' '.img_picto($label, $picto); @@ -617,7 +624,6 @@ class Entrepot extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result=''; - $label = ''; $label = '' . $langs->trans("ShowWarehouse").''; $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->ref)?(empty($this->label)?$this->libelle:$this->label):$this->ref); @@ -724,9 +730,9 @@ class Entrepot extends CommonObject /** * Return array of children warehouses ids from $id warehouse (recursive function) * - * @param int $id id parent warehouse - * @param array $TChildWarehouses array which will contain all children (param by reference) - * @return array $TChildWarehouses array which will contain all children + * @param int $id id parent warehouse + * @param integer[] $TChildWarehouses array which will contain all children (param by reference) + * @return integer[] $TChildWarehouses array which will contain all children */ function get_children_warehouses($id, &$TChildWarehouses) { From c3d1ed73d2be807b7956c1fb0b8682d0c46382e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 11:17:07 +0100 Subject: [PATCH 24/30] variables does not seem to be defined for all execution paths --- htdocs/core/boxes/box_produits_alerte_stock.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index c8c3d9c94b6..e041c0ab197 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005-2012 Maxime Kohlhaas - * Copyright (C) 2015 Frederic France + * Copyright (C) 2015-2019 Frédéric France * Copyright (C) 2015 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -117,6 +117,8 @@ class box_produits_alerte_stock extends ModeleBoxes while ($line < $num) { $objp = $db->fetch_object($result); $datem=$db->jdate($objp->tms); + $price = ''; + $price_base_type = ''; // Multilangs if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active From b75519fefea8885092077fc2ebf4c6a98627fcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 11:25:49 +0100 Subject: [PATCH 25/30] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 752d2406ea4..90809c68a05 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2015-2017 Marcos García * Copyright (C) 2015-2017 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1140,7 +1140,7 @@ class FormMail extends Form * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) * @param int $active 1=Only active template, 0=Only disabled, -1=All * @param string $label Label of template - * @return ModelMail One instance of ModelMail + * @return ModelMail|integer One instance of ModelMail or -1 if error */ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') { From b8df685186a839ae7ed6664ff7439591b1a479e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Feb 2019 14:11:53 +0100 Subject: [PATCH 26/30] Update payment.php --- htdocs/stripe/payment.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index bb6a6f1dbb2..50d64521621 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -78,7 +78,12 @@ if ($facid > 0) $ret=$object->fetch($facid); } -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +if (! empty($conf->stripe->enabled)) +{ + access_forbidden(); +} + +if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { $service = 'StripeTest'; $servicestatus = '0'; From 3d0af97e79934afeff07f80383dfb2e6d3db87ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Feb 2019 14:24:37 +0100 Subject: [PATCH 27/30] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index ceaca36e39d..3a36f711e4e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -921,10 +921,10 @@ class Invoices extends DolibarrApi } /** - * Make credt note from invoice + * Create credit note from invoice * * @param int $id Invoice ID - * @url POST {id}/makecreditnote + * @url POST {id}/createCreditNote * * @return array An invoice object * @@ -934,7 +934,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function makecreditnote($id) + function createCreditNote($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -960,7 +960,7 @@ class Invoices extends DolibarrApi { $this->invoice->fetch_lines(); - // Boucle sur chaque taux de tva + // Loop on each vat rate $i=0; foreach($this->invoice->lines as $line) { From 5bf3a1f175fff94df4f39be7660dfd7eb5995b2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Feb 2019 14:36:51 +0100 Subject: [PATCH 28/30] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3a36f711e4e..60c034bc240 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -921,7 +921,7 @@ class Invoices extends DolibarrApi } /** - * Create credit note from invoice + * Create a discount (credit available) for a credit note or a deposit. * * @param int $id Invoice ID * @url POST {id}/createCreditNote @@ -934,7 +934,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function createCreditNote($id) + function markAsCreditAvailable($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); From eb733728c3420aae5c02568f4e07f2900bfd7274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Feb 2019 14:37:09 +0100 Subject: [PATCH 29/30] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 60c034bc240..0cb005ddba5 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -924,7 +924,7 @@ class Invoices extends DolibarrApi * Create a discount (credit available) for a credit note or a deposit. * * @param int $id Invoice ID - * @url POST {id}/createCreditNote + * @url POST {id}/markAsCreditAvailable * * @return array An invoice object * From ca456512657be03f972cbcd6cb16e21844011b34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Feb 2019 14:38:13 +0100 Subject: [PATCH 30/30] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 0cb005ddba5..afecfd33b45 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -956,7 +956,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Thirdparty not found'); } - if (! $object->paye) // protection against multiple submit + if (! $this->invoice->paye) // protection against multiple submit { $this->invoice->fetch_lines(); @@ -1015,7 +1015,7 @@ class Invoices extends DolibarrApi } else { - throw new RestException(500, 'Discount error'); + throw new RestException(500, 'Discount creation error'); $this->db->rollback(); } }