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 { 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=''; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3056fc1c7f4..afecfd33b45 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -920,6 +920,118 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } + /** + * Create a discount (credit available) for a credit note or a deposit. + * + * @param int $id Invoice ID + * @url POST {id}/markAsCreditAvailable + * + * @return array An invoice object + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + */ + function markAsCreditAvailable($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 (! $this->invoice->paye) // protection against multiple submit + { + $this->invoice->fetch_lines(); + + // Loop on each vat rate + $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 creation 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 * 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) { 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') 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(); 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 ''; 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'); ?> 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/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 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 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 */ diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 752d2406ea4..6ea2e01fbfc 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 @@ -455,7 +455,7 @@ class FormMail extends Form } if (! empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. { - $out.= ''; + // print ''; } else { @@ -410,13 +410,13 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($error == 0) { if (! $silent) print ''; - if (! $silent) print ''."\n"; + if (! $silent) print ''."\n"; $ok = 1; } else { if (! $silent) print ''; - if (! $silent) print ''."\n"; + if (! $silent) print ''."\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 '
'; + $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 @@ -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 = '') { 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).'%').'
'; 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 'OKOK
'.$langs->trans("ProcessMigrateScript").''.$langs->trans("OK").'
'.$langs->trans("OK").'
'.$langs->trans("ProcessMigrateScript").''.$langs->trans("KO").'
'.$langs->trans("KO").'
'; 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++; 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(); 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 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) { diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index bf8802f4c89..50d64521621 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 @@ -80,22 +80,29 @@ if ($facid > 0) if (! empty($conf->stripe->enabled)) { - $service = 'StripeTest'; - $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeLive'; - $servicestatus = 0; - } - - $stripe=new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) + access_forbidden(); } +if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) +{ + $service = 'StripeTest'; + $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')); - /* * Actions */ diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 467d242a0c8..b0575a53ee4 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 @@ -71,7 +71,6 @@ else $service = 'StripeLive'; $servicestatus = '1'; } - $stripeacc = $stripe->getStripeAccount($service); /*if (empty($stripeaccount)) {