diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index a2aabaeb81b..da9942fce44 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -81,7 +81,7 @@ if ($nolinesbefore) { print ''; } ?> - trans('ManufacturingEfficiency'); ?> + textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')); ?>   trans('ConfirmSendingEmailing').'
'; $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 300); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); } } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 0c43475f2fb..cf059f1cdf1 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -877,12 +877,12 @@ if ($resql) } if (! empty($arrayfields['bu.label']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['ba.ref']['checked'])) { - print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + print ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || ! empty($ref)?' disabled="disabled"':''), 0, 'maxwidth100'); print ''; } if (! empty($arrayfields['b.debit']['checked'])) @@ -940,7 +940,7 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], 'bu.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder); if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1337,7 +1337,7 @@ if ($resql) // Bank account if (! empty($arrayfields['ba.ref']['checked'])) { - print ''; + print ''; print $bankaccount->getNomUrl(1); print "\n"; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 28483dfbf2c..4fbcc3cbd01 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4602,6 +4602,7 @@ class FactureLigne extends CommonInvoiceLine if ($result <= 0) { $this->error='ErrorProductIdDoesNotExists'; + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index a58a768eace..bf9b617693f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -506,7 +506,7 @@ class CMailFile } $sendingmode = $this->sendmode; - if (! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') + if ($this->context == 'emailing' && ! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // List of sending methods $listofmethods=array(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0c22b463975..f0b116a06fe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3649,9 +3649,10 @@ class Form * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param string $moreattrib To add more attribute on select * @param int $showcurrency Show currency in label + * @param string $morecss More CSS * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - public function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0) + public function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') { // phpcs:enable global $langs, $conf; @@ -3674,7 +3675,7 @@ class Form $i = 0; if ($num) { - print ''; if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f6efc4ec093..b729ad51fc5 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -688,7 +688,9 @@ class FormFile $out.= ''; $addcolumforpicto=($delallowed || $printer || $morepicto); - $out.= ''; + $colspan = (3+($addcolumforpicto?1:0)); $colspanmore = 0; + + $out.= ''; // Model if (! empty($modellist)) @@ -745,13 +747,17 @@ class FormFile { foreach($hookmanager->hooks['formfile'] as $module) { - if (method_exists($module, 'formBuilddocLineOptions')) $out .= ''; + if (method_exists($module, 'formBuilddocLineOptions')) + { + $colspanmore++; + $out .= ''; + } } } $out.= ''; // Execute hooks - $parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart); + $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'modulepart'=>$modulepart); if (is_object($hookmanager)) { $reshook = $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); @@ -848,14 +854,17 @@ class FormFile if (is_object($hookmanager)) { - $parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart,'relativepath'=>$relativepath); + $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart,'relativepath'=>$relativepath); $res = $hookmanager->executeHooks('formBuilddocLineOptions', $parameters, $file); if (empty($res)) { $out.= $hookmanager->resPrint; // Complete line $out.= ''; } - else $out = $hookmanager->resPrint; // Replace line + else + { + $out = $hookmanager->resPrint; // Replace all $out + } } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 40c5ef8c048..fe00f803a6b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -196,6 +196,7 @@ class Translate $modulename = ''; // Search if a module directory name is provided into lang file name + $regs=array(); if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs)) { $newdomain = $regs[1]; @@ -223,7 +224,7 @@ class Translate return -1; } - foreach($this->dir as $keydir => $searchdir) + foreach($this->dir as $searchdir) { // Directory of translation files $file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang"; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 575cf2256ef..b05f118b08b 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -284,7 +284,7 @@ abstract class DoliDB implements Database if ($string==0 || $string=="0000-00-00 00:00:00") return ''; $string=preg_replace('/([^0-9])/i', '', $string); $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), $gm); + $date=dol_mktime((int) substr($tmp, 8, 2), (int) substr($tmp, 10, 2), (int) substr($tmp, 12, 2), (int) substr($tmp, 4, 2), (int) substr($tmp, 6, 2), (int) substr($tmp, 0, 4), $gm); return $date; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bce137d1e11..12449d201f6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1982,7 +1982,7 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ //var_dump($localtz); //var_dump($year.'-'.$month.'-'.$day.'-'.$hour.'-'.$minute); $dt = new DateTime(null, $localtz); - $dt->setDate($year, $month, $day); + $dt->setDate((int) $year, (int) $month, (int) $day); $dt->setTime((int) $hour, (int) $minute, (int) $second); $date=$dt->getTimestamp(); // should include daylight saving time //var_dump($date); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index e6354c01105..0d008cea93d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2076,17 +2076,13 @@ else if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int')) { print ''; - + // Num print ''; print $numline; print ''; - - /*print ''; - print img_picto($langs->trans("Document"), "object_generic"); - print ' '.$piece_comptable.''; - print '';*/ - + // Date print ''.dol_print_date($db->jdate($line->date), 'day').''; + // Project if (! empty($conf->projet->enabled)) { print ''; @@ -2094,21 +2090,26 @@ else { $projecttmp->id=$line->fk_project; $projecttmp->ref=$line->projet_ref; + $projecttmp->title=$line->projet_title; print $projecttmp->getNomUrl(1); } print ''; } + // IK if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); print ''; } + // Type of fee print ''; $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); print $labeltype; print ''; + // Comment print ''.dol_nl2br($line->comments).''; + // VAT rate print ''.vatrate($line->vatrate, true).''; // Unit price HT print ''; @@ -2716,9 +2717,6 @@ if ($action != 'create' && $action != 'edit') print ''; -//$conf->global->DOL_URL_ROOT_DOCUMENT_PHP=dol_buildpath('/expensereport/documentwrapper.php',1); - - // Select mail models is same action as presend if (GETPOST('modelselected', 'alpha')) { $action = 'presend'; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 8028dff3855..a583f195d02 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -71,6 +71,11 @@ $error = 0; * Actions */ +if (GETPOST('cancel', 'alpha')) +{ + $action = ''; +} + // If create a request if ($action == 'create') { @@ -193,7 +198,35 @@ if ($action == 'create') } } -if ($action == 'update') +if ($action == 'update' && GETPOSTISSET('savevalidator') && ! empty($user->rights->holiday->approve)) +{ + $object = new Holiday($db); + $object->fetch($id); + + $object->oldcopy = dol_clone($object); + + $object->fk_validator = GETPOST('valideur', 'int'); + + if ($object->fk_validator != $object->oldcopy->fk_validator) + { + $verif = $object->update($user); + + if ($verif <= 0) + { + setEventMessages($object->error, $object->errors, 'warnings'); + $action='editvalidator'; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + + $action = ''; +} + +if ($action == 'update' && ! GETPOSTISSET('savevalidator')) { $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); @@ -1087,9 +1120,10 @@ else { $head=holiday_prepare_head($object); - if ($action == 'edit' && $object->statut == 1) + if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) { - $edit = true; + if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) $edit = true; + print '
'."\n"; print ''."\n"; print ''."\n"; @@ -1129,7 +1163,7 @@ else $starthalfday=($object->halfday == -1 || $object->halfday == 2)?'afternoon':'morning'; $endhalfday=($object->halfday == 1 || $object->halfday == 2)?'morning':'afternoon'; - if(!$edit) + if (!$edit) { print ''; print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; @@ -1178,7 +1212,7 @@ else print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).''; print ''; - if ($object->statut == 5) + if ($object->statut == Holiday::STATUS_REFUSED) { print ''; print ''.$langs->trans('DetailRefusCP').''; @@ -1228,25 +1262,40 @@ else } // Validator - if (!$edit) { + if (!$edit && $action != 'editvalidator') { print ''; print ''; - if ($object->statut == 3 || $object->statut == 4) print $langs->trans('ApprovedBy'); + if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) print $langs->trans('ApprovedBy'); else print $langs->trans('ReviewedByCP'); print ''; - print ''.$valideur->getNomUrl(-1).''; + print ''.$valideur->getNomUrl(-1); + $include_users = $object->fetch_users_approver_holiday(); + if (is_array($include_users) && in_array($user->id, $include_users) && $object->statut != Holiday::STATUS_DRAFT) + { + print ''.img_edit($langs->trans("Edit")).''; + } + print ''; print ''; } else { print ''; print ''.$langs->trans('ReviewedByCP').''; print ''; $include_users = $object->fetch_users_approver_holiday(); + if (! in_array($object->fk_validator, $include_users)) // Add the current validator to the list to not lose it when editing. + { + $include_users[]=$object->fk_validator; + } if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); else { - $s=$form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id)), 0, $include_users); + $s=$form->select_dolusers($object->fk_validator, "valideur", (($action == 'editvalidator') ? 0 : 1), ($user->admin ? '' : array($user->id)), 0, $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } + if ($action == 'editvalidator') + { + print ''; + print ''; + } print ''; print ''; } @@ -1255,19 +1304,19 @@ else print ''.$langs->trans('DateCreateCP').''; print ''.dol_print_date($object->date_create, 'dayhour').''; print ''; - if ($object->statut == 3 || $object->statut == 4) { + if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) { print ''; print ''.$langs->trans('DateValidCP').''; print ''.dol_print_date($object->date_valid, 'dayhour').''; // warning: date_valid is approval date on holiday module print ''; } - if ($object->statut == 4) { + if ($object->statut == Holiday::STATUS_CANCELED) { print ''; print ''.$langs->trans('DateCancelCP').''; print ''.dol_print_date($object->date_cancel, 'dayhour').''; print ''; } - if ($object->statut == 5) { + if ($object->statut == Holiday::STATUS_REFUSED) { print ''; print ''.$langs->trans('DateRefusCP').''; print ''.dol_print_date($object->date_refuse, 'dayhour').''; @@ -1325,20 +1374,21 @@ else print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleSetToDraft"), $langs->trans("ConfirmSetToDraft"), "confirm_draft", '', 1, 1); } - - if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) + if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) { - print '
'; - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) + if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) { - print ''; + print '
'; + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) + { + print ''; + } + print '
'; } - print '
'; print '
'; } - if (! $edit) { print '
'; diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 269242b910b..d3c26c8e65a 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -37,3 +37,4 @@ PAYBOX_PAYONLINE_SENDEMAIL=Email notification after payment attempt (success or PAYBOX_PBX_SITE=Value for PBX SITE PAYBOX_PBX_RANG=Value for PBX Rang PAYBOX_PBX_IDENTIFIANT=Value for PBX ID +PAYBOX_HMAC_KEY=HMAC key \ No newline at end of file diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 3c761b930e3..abad76ce228 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -73,7 +73,7 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error++; - + if (! $error) { @@ -151,7 +151,7 @@ print ''; print ''; print ''.$langs->trans("PAYBOX_HMAC_KEY").''; print ''; -print '
'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')'; +print '
'.$langs->trans("Example").': 1A2B3C4D5E6F'; print ''; print ''; @@ -181,7 +181,8 @@ print ''; print ''; print ''.$langs->trans("PAYBOX_CGI_URL_V2").''; print ''; -print '
'.$langs->trans("Example").': http://mysite/cgi-bin/modulev2_redhat72.cgi'; +print '
'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/'; +print '
'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/'; print ''; diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php index 7dca957e489..2d9eceb4a5f 100644 --- a/htdocs/paybox/lib/paybox.lib.php +++ b/htdocs/paybox/lib/paybox.lib.php @@ -78,15 +78,15 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) return -1; } + $conf->global->PAYBOX_HASH = 'sha512'; + // Definition des parametres vente produit pour paybox - $IBS_CMD=$TAG; + $IBS_CMD=$TAG; $IBS_TOTAL=$PRICE*100; // En centimes $IBS_MODE=1; // Mode formulaire $IBS_PORTEUR=$EMAIL; $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; // Format des parametres du get de validation en reponse (url a definir sous paybox) $IBS_TXT=' '; // Use a space - $IBS_BOUTPI=$langs->trans("Wait"); - //$IBS_BOUTPI=''; $IBS_EFFECTUE=$urlok; $IBS_ANNULE=$urlko; $IBS_REFUSE=$urlko; @@ -102,7 +102,9 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) $IBS_OUTPUT='E'; $PBX_SOURCE='HTML'; $PBX_TYPEPAIEMENT='CARTE'; - + $PBX_HASH = $conf->global->PAYBOX_HASH; + $PBX_TIME = dol_print_date(dol_now(), 'dayhourrfc', 'gmt'); + $msg = "PBX_IDENTIFIANT=".$PBX_IDENTIFIANT. "&PBX_MODE=".$IBS_MODE. "&PBX_SITE=".$IBS_SITE. @@ -122,11 +124,13 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) "&PBX_OUTPUT=".$IBS_OUTPUT. "&PBX_SOURCE=".$PBX_SOURCE. "&PBX_TYPEPAIEMENT=".$PBX_TYPEPAIEMENT; - + "&PBX_HASH=".$PBX_HASH; + "&PBX_TIME=".$PBX_TIME; + $binKey = pack("H*", dol_decode($conf->global->PAYBOX_HMAC_KEY)); - - $hmac = strtoupper(hash_hmac('sha512', $msg, $binKey)); - + + $hmac = strtoupper(hash_hmac($PBX_HASH, $msg, $binKey)); + dol_syslog("Soumission Paybox", LOG_DEBUG); dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); @@ -147,10 +151,12 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTIFIANT", LOG_DEBUG); dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG); dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG); + dol_syslog("PBX_HASH: $PBX_HASH", LOG_DEBUG); + dol_syslog("PBX_TIME: $PBX_TIME", LOG_DEBUG); header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print "\n"; @@ -182,6 +188,9 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) print ''."\n"; print ''."\n"; print ''."\n"; + print ''."\n"; + print ''."\n"; + // Footprint of parameters print ''."\n"; print ''."\n"; diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index de928a95c50..6708062fc51 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -51,7 +51,8 @@ dol_include_once("/cron/class/cronjob.class.php"); global $langs, $conf; // Language Management -$langs->loadLangs(array("admin", "cron")); +$langs->loadLangs(array("admin", "cron", "dict")); + @@ -59,6 +60,9 @@ $langs->loadLangs(array("admin", "cron")); * View */ +// current date +$now=dol_now(); + // Check the key, avoid that a stranger starts cron $key = GETPOST('securitykey', 'alpha'); if (empty($key)) @@ -84,15 +88,15 @@ $result=$user->fetch('', $userlogin); if ($result < 0) { echo "User Error:".$user->error; - dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_WARNING); + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); exit; } else { if (empty($user->id)) { - echo " User user login:".$userlogin." do not exists"; - dol_syslog(" User user login:".$userlogin." do not exists", LOG_WARNING); + echo " User login:".$userlogin." do not exists"; + dol_syslog(" User login:".$userlogin." do not exists", LOG_ERR); exit; } } @@ -103,8 +107,7 @@ $id = GETPOST('id', 'alpha'); // We accept non numeric id. We will filter later. $object = new Cronjob($db); $filter=array(); -if (! empty($id)) -{ +if (! empty($id)) { if (! is_numeric($id)) { echo "Error: Bad value for parameter job id"; @@ -118,7 +121,7 @@ $result = $object->fetch_all('ASC,ASC,ASC', 't.priority,t.entity,t.rowid', 0, 0, if ($result<0) { echo "Error: ".$object->error; - dol_syslog("cron_run_jobs.php fetch Error".$object->error, LOG_WARNING); + dol_syslog("cron_run_jobs.php fetch Error".$object->error, LOG_ERR); exit; } @@ -132,37 +135,76 @@ foreach($object->lines as $val) // TODO Duplicate code. This sequence of code must be shared with code into cron_run_jobs.php script. // current date -$now=dol_now(); $nbofjobs=count($qualifiedjobs); $nbofjobslaunchedok=0; $nbofjobslaunchedko=0; if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) { - // Loop over job + $savconf = dol_clone($conf); + + // Loop over job foreach($qualifiedjobs as $line) { - dol_syslog("cron_run_jobs.php cronjobid: ".$line->id, LOG_WARNING); + dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); + echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label; - //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database + // Force reload of setup for the current entity + if ($line->entity != $conf->entity) + { + dol_syslog("cron_run_jobs.php we work on another entity so we reload user and conf", LOG_DEBUG); + echo " -> we change entity so we reload user and conf"; + + $conf->entity = (empty($line->entity)?1:$line->entity); + $conf->setValues($db); // This make also the $mc->setValues($conf); that reload $mc->sharings + + // Force recheck that user is ok for the entity to process and reload permission for entity + if ($conf->entity != $user->entity && $user->entity != 0) + { + $result=$user->fetch('', $userlogin, '', 0, $conf->entity); + if ($result < 0) + { + echo "\nUser Error: ".$user->error."\n"; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit(-1); + } + else + { + if ($result == 0) + { + echo "\nUser login: ".$userlogin." does not exists for entity ".$conf->entity."\n"; + dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); + exit(-1); + } + } + $user->getrights(); + } + } + + //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourtext')." line->dateend:".dol_print_date($line->dateend, 'dayhourtext')." now:".dol_print_date($now, 'dayhourtext')); + echo " - qualified"; + + dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); if ($result<0) { - echo "Error cronjob->fetch: ".$cronjob->error."
\n"; + echo "Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n"; + echo "Failed to fetch job ".$line->id."\n"; dol_syslog("cron_run_jobs.php::fetch Error".$cronjob->error, LOG_ERR); exit; } - // Execut job + // Execute job $result=$cronjob->run_jobs($userlogin); if ($result < 0) { - echo "Error cronjob->run_job: ".$cronjob->error."
\n"; - dol_syslog("cron_run_jobs.php::run_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjobid: ".$line->id." cronjob->run_job: ".$cronjob->error."\n"; + echo "At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.\n"; + echo "You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; + dol_syslog("cron_run_jobs.php::run_jobs Error".$cronjob->error, LOG_ERR); $nbofjobslaunchedko++; } else @@ -170,16 +212,30 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) $nbofjobslaunchedok++; } + echo " - result of run_jobs = ".$result; + // We re-program the next execution and stores the last execution time for this job $result=$cronjob->reprogram_jobs($userlogin, $now); if ($result<0) { - echo "Error cronjob->reprogram_job: ".$cronjob->error."
\n"; - dol_syslog("cron_run_jobs.php::reprogram_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n"; + echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; + dol_syslog("cron_run_jobs.php::reprogram_jobs Error".$cronjob->error, LOG_ERR); exit; } + + echo " - reprogrammed\n"; + } + else + { + echo " - not qualified\n"; + + dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); } } + + $conf = $savconf; + echo "Result: ".($nbofjobs)." jobs - ".($nbofjobslaunchedok+$nbofjobslaunchedko)." launched = ".$nbofjobslaunchedok." OK + ".$nbofjobslaunchedko." KO"; } else diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7eea7e45df6..145df4f9e94 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -355,7 +355,7 @@ if ($action == 'dopayment') if ($paymentmethod == 'paybox') { $PRICE=price2num(GETPOST("newamount"), 'MT'); - $email=GETPOST("email", 'alpha'); + $email=$conf->global->ONLINE_PAYMENT_SENDEMAIL; $thirdparty_id=GETPOST('thirdparty_id', 'int'); $origfulltag=GETPOST("fulltag", 'alpha'); @@ -754,7 +754,7 @@ if (! empty($conf->paypal->enabled)) } if (! empty($conf->paybox->enabled)) { - + print ''."\n"; } if (! empty($conf->stripe->enabled)) { diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 0f4f1fecde7..c8060805872 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -24,17 +24,13 @@ * \ingroup cron * \brief Execute pendings jobs */ -if (! defined('NOTOKENRENEWAL')) - define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) - define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) - define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) - define('NOREQUIREAJAX', '1'); -if (! defined('NOLOGIN')) - define('NOLOGIN', '1'); -// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOLOGIN')) define('NOLOGIN','1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); @@ -68,12 +64,14 @@ $userlogin = $argv[2]; $version = DOL_VERSION; $error = 0; +// Language Management +$langs->loadLangs(array('main', 'admin', 'cron', 'dict')); + + /* * Main */ -$langs->loadLangs(array('main','dict')); - // current date $now = dol_now(); @@ -148,31 +146,66 @@ if (! empty($id)) { $result = $object->fetch_all('ASC,ASC,ASC', 't.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0); if ($result < 0) { echo "Error: " . $object->error; - dol_syslog("cron_run_jobs.php:: fetch Error " . $object->error, LOG_ERR); + dol_syslog("cron_run_jobs.php fetch Error " . $object->error, LOG_ERR); exit(- 1); } $qualifiedjobs = array(); foreach ($object->lines as $val) { if (! verifCond($val->test)) + { continue; + } $qualifiedjobs[] = $val; } -// TODO Duplicate. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page. +// TODO Duplicate code. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page. $nbofjobs = count($qualifiedjobs); $nbofjobslaunchedok = 0; $nbofjobslaunchedko = 0; if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { + $savconf = dol_clone($conf); + // Loop over job foreach ($qualifiedjobs as $line) { - dol_syslog("cron_run_jobs.php cronjobid: " . $line->id . " priority=" . $line->priority . " entity=" . $line->entity . " label=" . $line->label, LOG_DEBUG); + dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); + echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label; - echo "cron_run_jobs.php cronjobid: " . $line->id . " priority=" . $line->priority . " entity=" . $line->entity . " label=" . $line->label; + // Force reload of setup for the current entity + if ($line->entity != $conf->entity) + { + dol_syslog("cron_run_jobs.php we work on another entity so we reload user and conf", LOG_DEBUG); + echo " -> we change entity so we reload user and conf"; - // If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database + $conf->entity = (empty($line->entity)?1:$line->entity); + $conf->setValues($db); // This make also the $mc->setValues($conf); that reload $mc->sharings + + // Force recheck that user is ok for the entity to process and reload permission for entity + if ($conf->entity != $user->entity && $user->entity != 0) + { + $result=$user->fetch('', $userlogin, '', 0, $conf->entity); + if ($result < 0) + { + echo "\nUser Error: ".$user->error."\n"; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit(-1); + } + else + { + if ($result == 0) + { + echo "\nUser login: ".$userlogin." does not exists for entity ".$conf->entity."\n"; + dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); + exit(-1); + } + } + $user->getrights(); + } + } + + //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { echo " - qualified"; @@ -200,7 +233,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { echo " - result of run_jobs = " . $result; - // we re-program the next execution and stores the last execution time for this job + // We re-program the next execution and stores the last execution time for this job $result = $cronjob->reprogram_jobs($userlogin, $now); if ($result < 0) { echo "Error cronjobid: " . $line->id . " cronjob->reprogram_job: " . $cronjob->error . "\n"; @@ -216,7 +249,11 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:" . dol_print_date($line->datenextrun, 'dayhourrfc') . " line->datestart:" . dol_print_date($line->datestart, 'dayhourrfc') . " line->dateend:" . dol_print_date($line->dateend, 'dayhourrfc') . " now:" . dol_print_date($now, 'dayhourrfc')); } } -} else { + + $conf = $savconf; +} +else +{ echo "cron_run_jobs.php no qualified job found\n"; }