From a77b343db2b028f6998f8ba2553aa6230bd7b44a Mon Sep 17 00:00:00 2001 From: Egils Consulting Date: Tue, 4 Aug 2020 21:58:01 +0200 Subject: [PATCH 01/86] Update api_supplier_invoices.class.php Unified names. Renamed variable to an english name $paiementid => $payment_mode_id Added hints where to look up the IDs needed. --- .../class/api_supplier_invoices.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 5ec2b6f49a6..7722f2584f4 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -384,12 +384,12 @@ class SupplierInvoices extends DolibarrApi * * @param int $id Id of invoice * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param int $payment_mode_id {@from body} Payment mode ID (look it up via REST GET to /setup/dictionary/payment_types) {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} - * @param int $accountid {@from body} Account Id {@min 1} - * @param string $num_payment {@from body} Payment number (optional) + * @param int $accountid {@from body} Bank account ID (look it up via REST GET to /bankaccounts) {@min 1} + * @param string $num_payment {@from body} Payment number (optional) * @param string $comment {@from body} Note (optional) - * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') + * @param string $chqemetteur {@from body} Payment issuer (mandatory if payment_mode_id corresponds to 'CHQ'-payment type) * @param string $chqbank {@from body} Issuer bank name (optional) * * @url POST {id}/payments @@ -416,12 +416,12 @@ class SupplierInvoices extends DolibarrApi if (!empty($conf->banque->enabled)) { if (empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); + throw new RestException(400, 'Bank account ID is mandatory'); } } - if (empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + if (empty($payment_mode_id)) { + throw new RestException(400, 'Payment mode ID is mandatory'); } @@ -452,8 +452,8 @@ class SupplierInvoices extends DolibarrApi $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; - $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); + $paiement->paiementid = $payment_mode_id; + $paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); $paiement->num_payment = $num_payment; $paiement->note_public = $comment; From f26a287d10781a48e996a6a59d8f2be32f74ae1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Aug 2020 23:50:01 +0200 Subject: [PATCH 02/86] Update api_supplier_invoices.class.php --- htdocs/fourn/class/api_supplier_invoices.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 7722f2584f4..db288a5169a 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -399,7 +399,7 @@ class SupplierInvoices extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; From b6af4014dec821d583e8e6b6d6205a241bfa2646 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 13 Jul 2020 13:08:15 +0200 Subject: [PATCH 03/86] hide eatby, sellby dates --- htdocs/fourn/commande/dispatch.php | 60 +++++++++++++++++------- htdocs/product/stock/productlot_card.php | 29 +++++++----- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c64d158ac2c..4b077d861f3 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -733,8 +733,12 @@ if ($id > 0 || !empty($ref)) { print ''.$langs->trans("Description").''; if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("batch_number").''; - print ''.$langs->trans("EatByDate").''; - print ''.$langs->trans("SellByDate").''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.$langs->trans("EatByDate").''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.$langs->trans("SellByDate").''; + } } else { print ''; print ''; @@ -819,8 +823,12 @@ if ($id > 0 || !empty($ref)) { print $linktoprod; print ""; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } else { print ''; print $linktoprod; @@ -828,8 +836,12 @@ if ($id > 0 || !empty($ref)) { print ''; print $langs->trans("ProductDoesNotUseBatchSerial"); print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } } else { print ''; @@ -896,14 +908,18 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; print ''; - print ''; - $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); - print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); - print ''; - print ''; - $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); - print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + $dlcdatesuffix = dol_mktime( 0, 0, 0, GETPOST( 'dlc' . $suffix . 'month' ), GETPOST( 'dlc' . $suffix . 'day' ), GETPOST( 'dlc' . $suffix . 'year' ) ); + print $form->selectDate( $dlcdatesuffix, 'dlc' . $suffix, '', '', 1, '' ); + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); + print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); + print ''; + } print ' '; // Supplier ref + Qty ordered + qty already dispatched } else { $type = 'dispatch'; @@ -1118,8 +1134,12 @@ if ($id > 0 || !empty($ref)) { print ''.$langs->trans("DateDeliveryPlanned").''; if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("batch_number").''; - print ''.$langs->trans("EatByDate").''; - print ''.$langs->trans("SellByDate").''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print '' . $langs->trans( "EatByDate" ) . ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print '' . $langs->trans( "SellByDate" ) . ''; + } } print ''.$langs->trans("QtyDispatched").''; print ''.$langs->trans("Warehouse").''; @@ -1174,8 +1194,12 @@ if ($id > 0 || !empty($ref)) { $lot=new Productlot($db); $lot->fetch(0, $objp->pid, $objp->batch); print ''.$lot->getNomUrl(1).''; - print ''.dol_print_date($lot->eatby, 'day').''; - print ''.dol_print_date($lot->sellby, 'day').''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print '' . dol_print_date( $lot->eatby, 'day' ) . ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print '' . dol_print_date( $lot->sellby, 'day' ) . ''; + } } else { print ''; print ''; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 9b6de313b65..f091de9d78e 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -327,21 +327,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Eat by - print ''; - print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + print $form->editfieldkey( $langs->trans( 'EatByDate' ), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker' ); + print ''; + print $form->editfieldval( $langs->trans( 'EatByDate' ), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker' ); + print ''; + print ''; + } // Sell by - print ''; - print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print ''; - + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + print $form->editfieldkey( $langs->trans( 'SellByDate' ), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker' ); + print ''; + print $form->editfieldval( $langs->trans( 'SellByDate' ), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker' ); + print ''; + print ''; + } // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From 819144700794ecc50e657c00a580fd4ec56aa14d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 13 Jul 2020 11:12:53 +0000 Subject: [PATCH 04/86] Fixing style errors. --- htdocs/fourn/commande/dispatch.php | 12 ++++++------ htdocs/product/stock/productlot_card.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 4b077d861f3..f3a1b1d86dd 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -910,8 +910,8 @@ if ($id > 0 || !empty($ref)) { print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ''; - $dlcdatesuffix = dol_mktime( 0, 0, 0, GETPOST( 'dlc' . $suffix . 'month' ), GETPOST( 'dlc' . $suffix . 'day' ), GETPOST( 'dlc' . $suffix . 'year' ) ); - print $form->selectDate( $dlcdatesuffix, 'dlc' . $suffix, '', '', 1, '' ); + $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year')); + print $form->selectDate($dlcdatesuffix, 'dlc' . $suffix, '', '', 1, ''); print ''; } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { @@ -1135,10 +1135,10 @@ if ($id > 0 || !empty($ref)) { if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("batch_number").''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print '' . $langs->trans( "EatByDate" ) . ''; + print '' . $langs->trans("EatByDate") . ''; } if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print '' . $langs->trans( "SellByDate" ) . ''; + print '' . $langs->trans("SellByDate") . ''; } } print ''.$langs->trans("QtyDispatched").''; @@ -1195,10 +1195,10 @@ if ($id > 0 || !empty($ref)) { $lot->fetch(0, $objp->pid, $objp->batch); print ''.$lot->getNomUrl(1).''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print '' . dol_print_date( $lot->eatby, 'day' ) . ''; + print '' . dol_print_date($lot->eatby, 'day') . ''; } if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print '' . dol_print_date( $lot->sellby, 'day' ) . ''; + print '' . dol_print_date($lot->sellby, 'day') . ''; } } else { print ''; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index f091de9d78e..0f706c3ccae 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -329,9 +329,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Eat by if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ''; - print $form->editfieldkey( $langs->trans( 'EatByDate' ), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker' ); + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval( $langs->trans( 'EatByDate' ), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker' ); + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print ''; print ''; } @@ -339,9 +339,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Sell by if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''; - print $form->editfieldkey( $langs->trans( 'SellByDate' ), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker' ); + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval( $langs->trans( 'SellByDate' ), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker' ); + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print ''; print ''; } From 2873e6bdcab43f696cfa0fdbaf32f4afd4874505 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 6 Aug 2020 15:51:12 +0200 Subject: [PATCH 05/86] hide dates in productlot_list --- htdocs/product/stock/productlot_list.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 0fb3c4a0388..58a03fd2563 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -99,6 +99,12 @@ $arrayfields = array( 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['t.sellby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['t.eatby']); +} // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { @@ -338,8 +344,8 @@ if ($resql) if (!empty($arrayfields['t.entity']['checked'])) print ''; if (!empty($arrayfields['t.batch']['checked'])) print ''; if (!empty($arrayfields['t.fk_product']['checked'])) print ''; - if (!empty($arrayfields['t.sellby']['checked'])) print ''; - if (!empty($arrayfields['t.eatby']['checked'])) print ''; + if (!empty($arrayfields['t.sellby']['checked']) && empty($conf->global->PRODUCT_DISABLE_SELLBY)) print ''; + if (!empty($arrayfields['t.eatby']['checked']) && empty($conf->global->PRODUCT_DISABLE_EATBY)) print ''; if (!empty($arrayfields['t.fk_user_creat']['checked'])) print ''; if (!empty($arrayfields['t.fk_user_modif']['checked'])) print ''; if (!empty($arrayfields['t.import_key']['checked'])) print ''; @@ -381,8 +387,8 @@ if ($resql) if (!empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.sellby']['checked']) && empty($conf->global->PRODUCT_DISABLE_SELLBY)) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.eatby']['checked']) && empty($conf->global->PRODUCT_DISABLE_EATBY)) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); @@ -442,12 +448,12 @@ if ($resql) print ''.$productstatic->getNomUrl(1).''; if (!$i) $totalarray['nbfield']++; } - if (!empty($arrayfields['t.sellby']['checked'])) + if (!empty($arrayfields['t.sellby']['checked']) && empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''.dol_print_date($db->jdate($obj->sellby), 'day').''; if (!$i) $totalarray['nbfield']++; } - if (!empty($arrayfields['t.eatby']['checked'])) + if (!empty($arrayfields['t.eatby']['checked']) && empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ''.dol_print_date($db->jdate($obj->eatby), 'day').''; if (!$i) $totalarray['nbfield']++; From df3fcec6c6349e1faa10118cb51316a6b0cbe396 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Wed, 19 Aug 2020 16:44:45 +0200 Subject: [PATCH 06/86] hide dates on erassortlot.php --- htdocs/product/reassortlot.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index de49a11fbc7..050d0d12f4b 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -284,8 +284,12 @@ if ($resql) print ''; print ' '; print ' '; - print ' '; - print ' '; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ' '; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ' '; + } print ' '; print ' '; print ''; @@ -302,8 +306,12 @@ if ($resql) print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center '); + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center '); + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center '); + } print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // TODO Add info of running suppliers/customers orders //print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); @@ -400,8 +408,12 @@ if ($resql) } print ''; - print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; - print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; + } print ''; //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; print $objp->stock_physique; From b777c625575d29875cba64caef27a8aae42ece94 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 20 Aug 2020 12:13:05 +0200 Subject: [PATCH 07/86] hide eatby sellby on product/stock/product --- htdocs/product/stock/product.php | 46 +++++++++++++------ .../product/stock/tpl/stockcorrection.tpl.php | 20 ++++---- .../product/stock/tpl/stocktransfer.tpl.php | 16 ++++--- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index af7a95fb95a..f4669c44cea 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -805,11 +805,18 @@ if (!$variants) { print ''.$langs->trans("EstimatedStockValueSellShort").''; print ''; if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { + $colspan = 3; print ''; print ''.$langs->trans("batch_number").''; - print ''.$langs->trans("EatByDate").''; - print ''.$langs->trans("SellByDate").''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $colspan--; + print ''.$langs->trans("EatByDate").''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $colspan--; + print ''.$langs->trans("SellByDate").''; + } + print ''; print ''; print ''; print ''; @@ -887,14 +894,18 @@ if (!$variants) { print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print ''; +// print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + print ''; print ''; print '
'; - print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); - print ''; - print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); + print ''; + print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; print '
'; @@ -911,9 +922,16 @@ if (!$variants) { print ''; print $product_lot_static->getNomUrl(1); print ''; - print ''.dol_print_date($pdluo->eatby, 'day').''; - print ''.dol_print_date($pdluo->sellby, 'day').''; - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + $colspan = 3; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $colspan--; + print ''.dol_print_date($pdluo->eatby, 'day').''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $colspan--; + print ''.dol_print_date($pdluo->sellby, 'day').''; + } + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; print ''; print ''; } diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 98826ca6799..88cced3b99d 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -103,14 +103,18 @@ if (!empty($conf->productbatch->enabled) && print ''; print ''; print ''; - print ''.$langs->trans("EatByDate").''; - $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); - print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); - print ''; - print ''.$langs->trans("SellByDate").''; - $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); - print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.$langs->trans("EatByDate").''; + $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.$langs->trans("SellByDate").''; + $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); + print ''; + } print ''; } diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index f725a5ebbfe..0164e99bd37 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -107,12 +107,16 @@ if (!empty($conf->productbatch->enabled) && print ''; print ''; - print ''.$langs->trans("EatByDate").''; - print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled - print ''; - print ''.$langs->trans("SellByDate").''; - print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.$langs->trans("EatByDate").''; + print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.$langs->trans("SellByDate").''; + print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print ''; + } print ''; } From b74113e2eb7e4964b705e064f38c3d77c58b379f Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 20 Aug 2020 12:13:27 +0200 Subject: [PATCH 08/86] hide eatby sellby on expedition --- htdocs/expedition/card.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 929e7ecafd0..94ace4ab64f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1300,8 +1300,12 @@ if ($action == 'create') $detail = ''; $detail .= $langs->trans("Batch").': '.$dbatch->batch; - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + } $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; $detail .= '
'; print $detail; From a5b4fcedb7a055329ab9c05693166850aa2865b9 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 20 Aug 2020 12:48:23 +0200 Subject: [PATCH 09/86] hide eatby sellby in reception --- htdocs/reception/card.php | 45 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 7bc99977943..27722c29ed4 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -966,8 +966,12 @@ if ($action == 'create') if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("batch_number").''; - print ''.$langs->trans("EatByDate").''; - print ''.$langs->trans("SellByDate").''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.$langs->trans("EatByDate").''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.$langs->trans("SellByDate").''; + } } print "\n"; } @@ -1114,12 +1118,16 @@ if ($action == 'create') if (!empty($product->status_batch)) { print ''; - print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); - print ''; - print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); + print ''; + } } else { print ''; } @@ -1807,10 +1815,14 @@ if ($action == 'create') if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) { print '
'; - print $langs->trans('EatByDate').' : '; - print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
'; - print $langs->trans('SellByDate').' : '; - print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, ""); + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print $langs->trans('EatByDate').' : '; + print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
'; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print $langs->trans('SellByDate').' : '; + print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, ""); + } print ''; } print ''; @@ -1856,11 +1868,14 @@ if ($action == 'create') $detail = ''; if ($lines[$i]->product->status_batch) { - $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; + $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); - - $detail .= '
'; + } + $detail .= '
'; print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); } else { From 179fc2e70a341b6c929872299bc2dae84618ab5d Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 20 Aug 2020 15:27:34 +0200 Subject: [PATCH 10/86] hide other eatby sellby dates --- htdocs/expedition/card.php | 8 ++++++-- htdocs/mrp/mo_movements.php | 6 ++++++ htdocs/product/stock/index.php | 16 ++++++++++++---- htdocs/product/stock/movement_list.php | 6 ++++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 94ace4ab64f..621d6421d2d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2307,8 +2307,12 @@ if ($action == 'create') foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch { $detail .= $langs->trans("Batch").': '.$dbatch->batch; - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + } $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; $detail .= '
'; } diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index f43ccd3dcd4..e281d45ee74 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -143,6 +143,12 @@ $arrayfields = array( //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['pl.eatby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['pl.sellby']); +} $objectlist->fields = dol_sort_array($objectlist->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index fc43d5e8ce3..5a7cd3b2d3d 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -159,8 +159,12 @@ if ($resql) if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("Batch").''; - print ''.$langs->trans("SellByDate").''; - print ''.$langs->trans("EatByDate").''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.$langs->trans("SellByDate").''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.$langs->trans("EatByDate").''; + } } print ''.$langs->trans("Warehouse").''; print ''.$langs->trans("FullList").''; @@ -191,8 +195,12 @@ if ($resql) if (!empty($conf->productbatch->enabled)) { print ''.$objp->batch.''; - print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; - print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; + } } print ''; print $warehouse->getNomUrl(1); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index c844bae01e2..ee4c77eb2e4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -121,6 +121,12 @@ $arrayfields = array( //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['pl.eatby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['pl.sellby']); +} // Security check if (!$user->rights->stock->mouvement->lire) { From 3c108e8bbf571d436b06a3ceeb7f77143674d900 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 20 Aug 2020 13:31:48 +0000 Subject: [PATCH 11/86] Fixing style errors. --- htdocs/product/stock/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index f4669c44cea..315a5993d92 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -894,7 +894,7 @@ if (!$variants) { print ''; print ''; print ''; -// print ''; + // print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print '
'; print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); From b1849aed5c418b182d79829cd731b8d543d97cb9 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 24 Aug 2020 07:53:25 +0200 Subject: [PATCH 12/86] fix for mistakenly uncommented code --- htdocs/product/stock/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 315a5993d92..9f7628edc25 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -894,7 +894,7 @@ if (!$variants) { print ''; print ''; print ''; - // print ''; + print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print '"; + print ''; } - print ""; - print ''; // Incoterms if (!empty($conf->incoterm->enabled)) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 7e8796e44f6..fa0ab11955a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2587,21 +2587,24 @@ if ($action == 'create') } // Bank Account - print '"; + print ''; } - print ""; - print ''; // Incoterms if (!empty($conf->incoterm->enabled)) From 9c54f8831fcfbf9696dd8493f3a7dc9e52fc02c0 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 28 Aug 2020 13:08:04 +0200 Subject: [PATCH 20/86] Show bank only when active (on new) --- htdocs/compta/facture/card.php | 15 +++++++++------ htdocs/fourn/facture/card.php | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 17f6898a1db..460e40a1de4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3397,13 +3397,16 @@ if ($action == 'create') print ''; // Bank Account - if (GETPOSTISSET('fk_account')) { - $fk_account = GETPOST('fk_account'); - } + if (!empty($conf->banque->enabled)) + { + if (GETPOSTISSET('fk_account')) { + $fk_account = GETPOST('fk_account'); + } - print ''; + print ''; + } // Project if (!empty($conf->projet->enabled)) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index fa0ab11955a..dcf6cc0bd3a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2013,9 +2013,12 @@ if ($action == 'create') print ''; // Bank Account - print ''; + if (!empty($conf->banque->enabled)) + { + print ''; + } // Multicurrency if (!empty($conf->multicurrency->enabled)) From 4c0e1d20d6064ab06610a0109d2273511cd13fd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Aug 2020 05:27:07 +0200 Subject: [PATCH 21/86] FIX CSS --- htdocs/theme/md/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3d8f424b8ce..d6b6f3d46e4 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2773,7 +2773,7 @@ a.tabTitle { white-space: nowrap; } .tabTitleText { - display: hidden; + display: none; } .imgTabTitle { max-height: 14px; From c8e0bcd710b4b1b5f9a4672fa67bf948bf03ee8b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 31 Aug 2020 17:09:14 +0200 Subject: [PATCH 22/86] NEW API get users by email / login --- htdocs/user/class/api_users.class.php | 78 +++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index d477e37c160..40a02dc8af1 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -1,6 +1,6 @@ -/* Copyright (C) 2030 Thibault FOUCART +/* Copyright (C) 2020 Thibault FOUCART * * 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 @@ -143,13 +143,13 @@ class Users extends DolibarrApi /** * Get properties of an user object - * Return an array with user informations * * @param int $id ID of user * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) * @return array|mixed data without useless information * - * @throws RestException + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function get($id, $includepermissions = 0) { @@ -174,6 +174,78 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } + + /** + * Get properties of an user object by login + * + * @param string $login Login of user + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed data without useless information + * + * @url GET login/{login} + * + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found + */ + public function getByLogin($login, $includepermissions = 0) + { + //if (!DolibarrApiAccess::$user->rights->user->user->lire) { + //throw new RestException(401); + //} + + $result = $this->useraccount->fetch('', $login); + if (!$result) + { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) + { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if ($includepermissions) { + $this->useraccount->getRights(); + } + + return $this->_cleanObjectDatas($this->useraccount); + } + + /** + * Get properties of an user object by Email + * + * @param string $email Email of user + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed data without useless information + * + * @url GET email/{email} + * + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found + */ + public function getByEmail($email, $includepermissions = 0) + { + //if (!DolibarrApiAccess::$user->rights->user->user->lire) { + //throw new RestException(401); + //} + + $result = $this->useraccount->fetch('', '', '', 0, -1, $email); + if (!$result) + { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) + { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if ($includepermissions) { + $this->useraccount->getRights(); + } + + return $this->_cleanObjectDatas($this->useraccount); + } /** * Get properties of user connected From fcc2ad8c9b1895920bba8a8c25621228513cee0d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 31 Aug 2020 15:11:05 +0000 Subject: [PATCH 23/86] Fixing style errors. --- htdocs/user/class/api_users.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 40a02dc8af1..c878d7dd376 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -174,7 +174,7 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } - + /** * Get properties of an user object by login * @@ -183,7 +183,7 @@ class Users extends DolibarrApi * @return array|mixed data without useless information * * @url GET login/{login} - * + * * @throws RestException 401 Insufficient rights * @throws RestException 404 User or group not found */ @@ -210,7 +210,7 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } - + /** * Get properties of an user object by Email * @@ -219,7 +219,7 @@ class Users extends DolibarrApi * @return array|mixed data without useless information * * @url GET email/{email} - * + * * @throws RestException 401 Insufficient rights * @throws RestException 404 User or group not found */ From 477f33f56cba686e7df3113362b9e35b5ad17ff7 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 31 Aug 2020 21:45:51 +0200 Subject: [PATCH 24/86] NEW standardizes API thirdparties by email with other object --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ba807fa1706..48b6f989408 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -85,7 +85,7 @@ class Thirdparties extends DolibarrApi * @param string $email Email of third party to load * @return array|mixed data without useless information * - * @url GET byEmail/{email} + * @url GET email/{email} * * @throws RestException */ From e353d4a42dfaba0dad394877f59de380936b822f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 03:59:57 +0200 Subject: [PATCH 25/86] Add tooltip if label truncated --- htdocs/comm/action/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index d78346efe74..31274bee5fd 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -716,7 +716,7 @@ if ($resql) // Label if (!empty($arrayfields['a.label']['checked'])) { - print ''; } From b69a992324a31e9df36efaf218bddb3f83ccdd49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 04:29:57 +0200 Subject: [PATCH 26/86] Fix option AGENDA_SUPPORT_PRIORITY_IN_EVENTS --- htdocs/comm/action/card.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index dcb72cd2a18..c75410f3cbd 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1579,9 +1579,11 @@ if ($id > 0) } // Priority - print ''; + if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + print ''; + } // Object linked if (!empty($object->fk_element) && !empty($object->elementtype)) From 13f91f1de89ce41dbff233f3434c59ffb2cd4dbe Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 1 Sep 2020 09:41:59 +0200 Subject: [PATCH 27/86] FIX getEmailTemplat() in sendEmailsReminder() reminder function --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9273352d2f5..e5686263878 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2005,7 +2005,7 @@ class ActionComm extends CommonObject //Select email template $formmail = new FormMail($this->db); - $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)'); + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); $res = $this->fetch($actionCommReminder->fk_actioncomm); From b747f6285ebf2158ddbb72bafcfe099b96968116 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 1 Sep 2020 10:01:59 +0200 Subject: [PATCH 28/86] Errors management --- htdocs/comm/action/class/actioncomm.class.php | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e5686263878..54b0b1f634e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1983,7 +1983,9 @@ class ActionComm extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - //Select all action comm reminder + $this->db->begin(); + + //Select all action comm reminder $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email' AND status = 0"; $resql = $this->db->query($sql); @@ -1994,7 +1996,7 @@ class ActionComm extends CommonObject $res = $actionCommReminder->fetch($obj->id); if($res < 0) { $error++; - $this->errors[] = "Failed to load invoice ActionComm Reminder"; + $errorsMsg[] = "Failed to load invoice ActionComm Reminder"; } if(!$error) @@ -2030,12 +2032,16 @@ class ActionComm extends CommonObject if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; else { - $this->errors[] = "Failed to load recipient"; + $errorsMsg[] = "Failed to load recipient"; $error++; } // Sender $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + if(empty($from)) { + $errorsMsg[] = "Failed to load recipient"; + $error++; + } // Errors Recipient $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; @@ -2050,7 +2056,7 @@ class ActionComm extends CommonObject $res = $actionCommReminder->update($user); if ($res < 0) { - $this->errors[] = "Failed to update status of ActionComm Reminder"; + $errorsMsg[] = "Failed to update status of ActionComm Reminder"; $error++; } else $nbMailSend++; @@ -2074,18 +2080,23 @@ class ActionComm extends CommonObject if(!$error) { - $this->db->begin(); - // Delete also very old past events (we do not keep more than 1 month record in past) $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $resql = $this->db->query($sql); - if($resql) $this->db->commit(); - else $this->db->rollback(); + if(!$resql) $error ++; } - return $error; + if(!$error) { + $this->db->commit(); + return 0; + } + else { + $this->db->rollback(); + return end($errorsMsg); + } + } /** From 86c6ef23e352f7d51a4833453b0c31b4dfef9a7d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 1 Sep 2020 10:05:55 +0200 Subject: [PATCH 29/86] Errors management v2 --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 54b0b1f634e..c91ac1a1abe 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2084,7 +2084,10 @@ class ActionComm extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $resql = $this->db->query($sql); - if(!$resql) $error ++; + if(!$resql) { + $errorsMsg[] = 'Failed to delete old reminders'; + $error ++; + } } @@ -2094,7 +2097,7 @@ class ActionComm extends CommonObject } else { $this->db->rollback(); - return end($errorsMsg); + return (!empty($errorsMsg)) ? end($errorsMsg) : $error; } } From 763515a4ca3613d4446a432657807831dcdc1d24 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 1 Sep 2020 08:17:19 +0000 Subject: [PATCH 30/86] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c91ac1a1abe..aaf160b9ec1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1989,22 +1989,19 @@ class ActionComm extends CommonObject $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email' AND status = 0"; $resql = $this->db->query($sql); - if($resql){ - while($obj = $this->db->fetch_object($resql)){ - + if ($resql){ + while ($obj = $this->db->fetch_object($resql)){ $actionCommReminder = new ActionCommReminder($this->db); $res = $actionCommReminder->fetch($obj->id); - if($res < 0) { + if ($res < 0) { $error++; $errorsMsg[] = "Failed to load invoice ActionComm Reminder"; } - if(!$error) + if (!$error) { - if ($actionCommReminder->dateremind <= dol_now()) { - //Select email template $formmail = new FormMail($this->db); $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); @@ -2030,15 +2027,14 @@ class ActionComm extends CommonObject $recipient = new User($this->db); $res = $recipient->fetch($actionCommReminder->fk_user); if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; - else - { + else { $errorsMsg[] = "Failed to load recipient"; $error++; } // Sender $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - if(empty($from)) { + if (empty($from)) { $errorsMsg[] = "Failed to load recipient"; $error++; } @@ -2061,14 +2057,12 @@ class ActionComm extends CommonObject } else $nbMailSend++; } - else - { + else { $errorsMsg[] = $cMailFile->error.' : '.$to; $error++; } } - else - { + else { $error++; } } @@ -2078,20 +2072,19 @@ class ActionComm extends CommonObject $error++; } - if(!$error) + if (!$error) { // Delete also very old past events (we do not keep more than 1 month record in past) $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $resql = $this->db->query($sql); - if(!$resql) { + if (!$resql) { $errorsMsg[] = 'Failed to delete old reminders'; $error ++; } - } - if(!$error) { + if (!$error) { $this->db->commit(); return 0; } From ba107361fd9f8b879a1d2d261360af4b526e54bb Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 1 Sep 2020 13:20:56 +0200 Subject: [PATCH 31/86] Allow click all num on comm. overview --- htdocs/comm/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index b542a110832..602cde69163 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles /* - * Draft proposals + * Draft customer proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { @@ -256,7 +256,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa print '
'; print '
'; print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); From 6d2aa6b65498713002ef94e6bd6493be8bc1d3f5 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 24 Aug 2020 15:26:06 +0200 Subject: [PATCH 13/86] Fix non-numeric value --- htdocs/fourn/class/paiementfourn.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e6795593721..6222329af16 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -177,7 +177,7 @@ class PaiementFourn extends Paiement foreach ($amounts as $key => $value) { - $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way, 'facture_fourn'); + $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value? $value : 0, $way, 'facture_fourn'); $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); From acb50950a4c190a269fb1f1d74a49fa396f7677f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 11:31:48 +0200 Subject: [PATCH 14/86] Add a default message to "actioncomm_send" template --- htdocs/core/class/html.formmail.class.php | 2 ++ htdocs/langs/en_US/other.lang | 1 + htdocs/langs/fr_FR/other.lang | 1 + 3 files changed, 4 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index aeec45555b2..1fef9012858 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1253,6 +1253,8 @@ class FormMail extends Form $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($type_template == 'fichinter_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); + } elseif ($type_template == 'actioncomm_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendActionComm"); } elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric"); } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 54c0572d453..ffc74c96d3b 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -99,6 +99,7 @@ PredefinedMailContentSendShipping=__(Hello)__\n\nPlease find shipping __REF__ at PredefinedMailContentSendFichInter=__(Hello)__\n\nPlease find intervention __REF__ attached\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.\n\n%s\n\n PredefinedMailContentGeneric=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendActionComm=__(Hello)__\n\nEvent reminder "__EVENT_LABEL__" on __EVENT_DATE__ at __EVENT_TIME__\n__(Sincerely)__\n\n__USER_SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index bd75f6c9035..729ab374319 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -101,6 +101,7 @@ PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNA PredefinedMailContentContact=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentLink=Vous pouvez cliquer sur le lien ci-dessous pour effectuer votre paiement si ce n'est déjà fait.\n\n%s\n\n +PredefinedMailContentSendActionComm=__(Hello)__\n\nRappel événement "__EVENT_LABEL__" le __EVENT_DATE__ à __EVENT_TIME__\n__(Sincerely)__\n\n__USER_SIGNATURE__ DemoDesc=Dolibarr est un logiciel de gestion proposant plusieurs modules métiers. Une démonstration qui inclut tous ces modules n'a pas de sens car ce cas n'existe jamais (plusieurs centaines de modules disponibles). Aussi, quelques profils type de démo sont disponibles. ChooseYourDemoProfil=Veuillez choisir le profil de démonstration qui correspond le mieux à votre activité… ChooseYourDemoProfilMore=...ou construisez votre propre profil
(sélection manuelle des modules) From f57325237aea5b77db1e013d46b5965f49f39710 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 12:30:59 +0200 Subject: [PATCH 15/86] WIP : sendEmailsReminder() --- htdocs/comm/action/class/actioncomm.class.php | 19 ++++++++++++++++++- htdocs/langs/en_US/members.lang | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e860217d03..f97a01f67e9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -28,6 +28,8 @@ */ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + /** @@ -1949,7 +1951,7 @@ class ActionComm extends CommonObject */ public function sendEmailsReminder() { - global $conf, $langs; + global $conf, $langs, $user; $error = 0; $this->output = ''; @@ -1976,6 +1978,21 @@ class ActionComm extends CommonObject // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done + $sql = "SELECT rowid as id, fk_email_template FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email'"; + $resql = $this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)){ + $formmail = new FormMail($this->db); + + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($obj->fk_email_template)) ? $obj->fk_email_template : 0, 1, '(SendingReminderActionComm)'); + + } + } else { + $error++; + } + + // Delete also very old past events (we do not keep more than 1 month record in past) $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $this->db->query($sql); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 5ef946ddf67..2f126b11fdf 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -117,6 +117,7 @@ SendingEmailOnMemberValidation=Sending email on new member validation SendingEmailOnNewSubscription=Sending email on new subscription SendingReminderForExpiredSubscription=Sending reminder for expired subscriptions SendingEmailOnCancelation=Sending email on cancelation +SendingReminderActionComm=Sending reminder for agenda event # Topic of email templates YourMembershipRequestWasReceived=Your membership was received. YourMembershipWasValidated=Your membership was validated From e3ce3cbb7c6e95eb0f8d35c888d6c48855fcb2d6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 15:49:56 +0200 Subject: [PATCH 16/86] Function sendEmailsReminder() --- htdocs/comm/action/class/actioncomm.class.php | 96 ++++++++++++++++--- htdocs/core/lib/functions.lib.php | 7 ++ htdocs/langs/en_US/other.lang | 2 +- htdocs/langs/fr_FR/other.lang | 2 +- 4 files changed, 94 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f97a01f67e9..54a7fd8e2f0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -29,6 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php'; + + @@ -1974,30 +1978,100 @@ class ActionComm extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $this->db->begin(); - - // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done - - $sql = "SELECT rowid as id, fk_email_template FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email'"; + //Select all action comm reminder + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email'"; $resql = $this->db->query($sql); if($resql){ while($obj = $this->db->fetch_object($resql)){ - $formmail = new FormMail($this->db); - $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($obj->fk_email_template)) ? $obj->fk_email_template : 0, 1, '(SendingReminderActionComm)'); + $actionCommReminder = new ActionCommReminder($this->db); + $res = $actionCommReminder->fetch($obj->id); + if($res < 0) { + $error++; + $this->errors[] = "Failed to load invoice ActionComm Reminder"; + } + if(!$error) + { + //Select email template + $formmail = new FormMail($this->db); + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)'); + + $res = $this->fetch($actionCommReminder->fk_actioncomm); + + if ($res > 0) + { + // PREPARE EMAIL + + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + + complete_substitutions_array($substitutionarray, $langs, $this); + + // Content + $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); + + //Topic + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : $langs->trans('EventReminder'); + + // Recipient + $recipient = new User($this->db); + $res = $recipient->fetch($actionCommReminder->fk_user); + if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; + else { + $this->errors[] = "Failed to load recipient"; + $error++; + } + + // Sender + $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + + // Errors Recipient + $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); + + // Sending Mail + if ($cMailFile->sendfile()) + { + $actionCommReminder->status=$actionCommReminder::STATUS_DONE; + $res = $actionCommReminder->update($user); + if($res<0) { + $this->errors[] = "Failed to update status of ActionComm Reminder"; + $error++; + } + else $nbMailSend++; + } + else + { + $errorsMsg[] = $cMailFile->error.' : '.$to; + $error++; + } + } + else + { + $error++; + } + } } } else { $error++; } + if(!$error) + { + $this->db->begin(); - // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; - $this->db->query($sql); + // Delete also very old past events (we do not keep more than 1 month record in past) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; + $resql = $this->db->query($sql); - $this->db->commit(); + if($resql) $this->db->commit(); + else $this->db->rollback(); + + } return $error; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8631e0e5663..74916ec62e1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6244,6 +6244,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'commande') $substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id; if (is_object($object) && $object->element == 'facture') $substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id; } + + if (is_object($object) && $object->element == 'action') + { + $substitutionarray['__EVENT_LABEL__'] = $object->label; + $substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, '%A %d %b %Y'); + $substitutionarray['__EVENT_TIME__'] = dol_print_date($object->datep, '%H:%M:%S'); + } } } if (empty($exclude) || !in_array('objectamount', $exclude)) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index ffc74c96d3b..4903bea90da 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -99,7 +99,7 @@ PredefinedMailContentSendShipping=__(Hello)__\n\nPlease find shipping __REF__ at PredefinedMailContentSendFichInter=__(Hello)__\n\nPlease find intervention __REF__ attached\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.\n\n%s\n\n PredefinedMailContentGeneric=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ -PredefinedMailContentSendActionComm=__(Hello)__\n\nEvent reminder "__EVENT_LABEL__" on __EVENT_DATE__ at __EVENT_TIME__\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendActionComm=Event reminder "__EVENT_LABEL__" on __EVENT_DATE__ at __EVENT_TIME__

This is an automatic message, please do not reply. DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 729ab374319..e666b6d6d80 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -101,7 +101,7 @@ PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNA PredefinedMailContentContact=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentLink=Vous pouvez cliquer sur le lien ci-dessous pour effectuer votre paiement si ce n'est déjà fait.\n\n%s\n\n -PredefinedMailContentSendActionComm=__(Hello)__\n\nRappel événement "__EVENT_LABEL__" le __EVENT_DATE__ à __EVENT_TIME__\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendActionComm=Rappel événement "__EVENT_LABEL__" le __EVENT_DATE__ à __EVENT_TIME__

Ceci est un message automatique, merci de ne pas répondre. DemoDesc=Dolibarr est un logiciel de gestion proposant plusieurs modules métiers. Une démonstration qui inclut tous ces modules n'a pas de sens car ce cas n'existe jamais (plusieurs centaines de modules disponibles). Aussi, quelques profils type de démo sont disponibles. ChooseYourDemoProfil=Veuillez choisir le profil de démonstration qui correspond le mieux à votre activité… ChooseYourDemoProfilMore=...ou construisez votre propre profil
(sélection manuelle des modules) From c0f254d10c675c8d34deed2971438683359c24b0 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 16:03:25 +0200 Subject: [PATCH 17/86] Translation + decode --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/langs/en_US/agenda.lang | 3 ++- htdocs/langs/fr_FR/agenda.lang | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 54a7fd8e2f0..2f99eef15c9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1979,7 +1979,7 @@ class ActionComm extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); //Select all action comm reminder - $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email'"; + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email' AND status = 0"; $resql = $this->db->query($sql); if($resql){ @@ -2013,7 +2013,7 @@ class ActionComm extends CommonObject $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); //Topic - $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : $langs->trans('EventReminder'); + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); // Recipient $recipient = new User($this->db); diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index bbfb143cee8..7b716d8050d 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -165,4 +165,5 @@ TimeType=Duration type ReminderType=Callback type AddReminder=Create an automatic reminder notification for this event ErrorReminderActionCommCreation=Error creating the reminder notification for this event -BrowserPush=Browser Notification \ No newline at end of file +BrowserPush=Browser Notification +EventReminder=Event Reminder \ No newline at end of file diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 80d1c953e0b..e53af5f75be 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -164,3 +164,4 @@ ReminderType=Type de rappel AddReminder=Créer une notification de rappel automatique pour cet évènement ErrorReminderActionCommCreation=Erreur lors de la création de la notification de rappel de cet événement BrowserPush=Notification navigateur +EventReminder=Rappel événement From 6562334f7b2138941f22af5fc182773201d99126 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 28 Aug 2020 09:37:18 +0200 Subject: [PATCH 18/86] FIX sendEmailsReminder() function --- htdocs/comm/action/class/actioncomm.class.php | 99 ++++++++++--------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2f99eef15c9..2bf5af2599e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1994,66 +1994,73 @@ class ActionComm extends CommonObject if(!$error) { - //Select email template - $formmail = new FormMail($this->db); - $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)'); - $res = $this->fetch($actionCommReminder->fk_actioncomm); - - if ($res > 0) + if ($actionCommReminder->dateremind <= dol_now()) { - // PREPARE EMAIL - // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + //Select email template + $formmail = new FormMail($this->db); + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)'); - complete_substitutions_array($substitutionarray, $langs, $this); + $res = $this->fetch($actionCommReminder->fk_actioncomm); - // Content - $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); - - //Topic - $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); - - // Recipient - $recipient = new User($this->db); - $res = $recipient->fetch($actionCommReminder->fk_user); - if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; - else { - $this->errors[] = "Failed to load recipient"; - $error++; - } - - // Sender - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - - // Errors Recipient - $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; - - // Mail Creation - $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); - - // Sending Mail - if ($cMailFile->sendfile()) + if ($res > 0) { - $actionCommReminder->status=$actionCommReminder::STATUS_DONE; - $res = $actionCommReminder->update($user); - if($res<0) { - $this->errors[] = "Failed to update status of ActionComm Reminder"; + // PREPARE EMAIL + + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + + complete_substitutions_array($substitutionarray, $langs, $this); + + // Content + $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); + + //Topic + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); + + // Recipient + $recipient = new User($this->db); + $res = $recipient->fetch($actionCommReminder->fk_user); + if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; + else + { + $this->errors[] = "Failed to load recipient"; + $error++; + } + + // Sender + $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + + // Errors Recipient + $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); + + // Sending Mail + if ($cMailFile->sendfile()) + { + $actionCommReminder->status = $actionCommReminder::STATUS_DONE; + $res = $actionCommReminder->update($user); + if ($res < 0) + { + $this->errors[] = "Failed to update status of ActionComm Reminder"; + $error++; + } + else $nbMailSend++; + } + else + { + $errorsMsg[] = $cMailFile->error.' : '.$to; $error++; } - else $nbMailSend++; } else { - $errorsMsg[] = $cMailFile->error.' : '.$to; $error++; } } - else - { - $error++; - } } } } else { From 216e22e50599bbbb9374ef38dd46d579de76faca Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 28 Aug 2020 12:53:30 +0200 Subject: [PATCH 19/86] Show bank only when bank module is active --- htdocs/compta/facture/card.php | 31 +++++++++++++++++-------------- htdocs/fourn/facture/card.php | 31 +++++++++++++++++-------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3d06f665e22..17f6898a1db 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4264,22 +4264,25 @@ if ($action == 'create') } // Bank Account - print '
'; - print ''; - print '
'; - print $langs->trans('BankAccount'); - print ''; - if (($action != 'editbankaccount') && $usercancreate) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print '
'; - if ($action == 'editbankaccount') + if (!empty($conf->banque->enabled)) { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $usercancreate) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print '
'; + if ($action == 'editbankaccount') + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print "
'; - print ''; - print '
'; - print $langs->trans('BankAccount'); - print ''; - if ($action != 'editbankaccount' && $usercancreate) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print '
'; - if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + if (!empty($conf->banque->enabled)) + { + print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if ($action != 'editbankaccount' && $usercancreate) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print '
'; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print "
'.$langs->trans('BankAccount').''; - $form->select_comptes($fk_account, 'fk_account', 0, '', 1); - print '
'.$langs->trans('BankAccount').''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print '
'.$langs->trans('BankAccount').''; - $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1); - print '
'.$langs->trans('BankAccount').''; + $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1); + print '
'; + print ''; print $actionstatic->label; print '
'.$langs->trans("Priority").''; - print ''; - print '
'.$langs->trans("Priority").''; + print ''; + print '
'; print ''; - print ''; + print ''; if ($num > 0) { @@ -309,7 +309,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa /* - * Draft orders + * Draft customer orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { @@ -338,7 +338,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'; print '
'.$langs->trans("SupplierProposalsDraft").($num ? ''.$num.'' : '').'
'.$langs->trans("SupplierProposalsDraft").' '.$num.'
'; print ''; - print ''; + print ''; if ($num > 0) { @@ -425,7 +425,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print '
'; print '
'.$langs->trans("DraftOrders").($num ? ''.$num.'' : '').'
'.$langs->trans("DraftOrders").' '.$num.'
'; print ''; - print ''; + print ''; if ($num > 0) { From 1b225706db237cbb2ebebe2330d59c782be69916 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 1 Sep 2020 14:48:03 +0200 Subject: [PATCH 32/86] FIX create remind : dateremind save --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c75410f3cbd..994613db8b1 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -405,7 +405,7 @@ if (empty($reshook) && $action == 'add') $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y'); } - $actionCommReminder->dateremind = $db->idate($dateremind); + $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; $actionCommReminder->fk_user = $user; $actionCommReminder->offsetunit = $offsetunit; From 5d40380a07d889c266214eabb79c608bb6811217 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 15:17:52 +0200 Subject: [PATCH 33/86] Add index on status --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 7 ++++++- .../install/mysql/tables/llx_actioncomm_reminder.key.sql | 2 +- htdocs/langs/en_US/companies.lang | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 92f08f43e67..17b58f278cf 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -301,7 +301,12 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_actioncomm integer NOT NULL; ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; -ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique, ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm); + +ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique; +ALTER TABLE llx_actioncomm_reminder ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm); + +ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_status (status); + ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehouse, fk_product, batch); diff --git a/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql b/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql index 634e474782a..6cc9a8cbd37 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm_reminder.key.sql @@ -15,9 +15,9 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_rowid (rowid); ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_dateremind (dateremind); ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_fk_user (fk_user); +ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_status (status); -- END MODULEBUILDER INDEXES ALTER TABLE llx_actioncomm_reminder ADD UNIQUE INDEX uk_actioncomm_reminder_unique(fk_actioncomm, fk_user, typeremind, offsetvalue, offsetunit); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 92674363ced..923ce91d74a 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -456,3 +456,6 @@ PaymentTermsSupplier=Payment Term - Vendor PaymentTypeBoth=Payment Type - Customer and Vendor MulticurrencyUsed=Use Multicurrency MulticurrencyCurrency=Currency +InEEC=Europe (EEC) +RestOfEurope=Rest of Europe (EEC) +OutOfEurope=Out of Europe (EEC) \ No newline at end of file From a626b252bd3a54f61d3c7a58d9da4166d007840b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 15:33:02 +0200 Subject: [PATCH 34/86] Optimize code --- htdocs/comm/action/class/actioncomm.class.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index aaf160b9ec1..fd41a9eadf4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1986,12 +1986,17 @@ class ActionComm extends CommonObject $this->db->begin(); //Select all action comm reminder - $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email' AND status = 0"; + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + $sql .= " WHERE typeremind = 'email' AND status = 0"; + $sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'"; + $sql .= $this->db->order("dateremind", "ASC"); $resql = $this->db->query($sql); - if ($resql){ - while ($obj = $this->db->fetch_object($resql)){ - $actionCommReminder = new ActionCommReminder($this->db); + if ($resql) { + $formmail = new FormMail($this->db); + $actionCommReminder = new ActionCommReminder($this->db); + + while ($obj = $this->db->fetch_object($resql)){ $res = $actionCommReminder->fetch($obj->id); if ($res < 0) { $error++; @@ -2000,14 +2005,11 @@ class ActionComm extends CommonObject if (!$error) { - if ($actionCommReminder->dateremind <= dol_now()) - { //Select email template - $formmail = new FormMail($this->db); $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); + // Load event $res = $this->fetch($actionCommReminder->fk_actioncomm); - if ($res > 0) { // PREPARE EMAIL @@ -2065,7 +2067,6 @@ class ActionComm extends CommonObject else { $error++; } - } } } } else { @@ -2075,7 +2076,8 @@ class ActionComm extends CommonObject if (!$error) { // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + $sql .= " WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32))."'"; $resql = $this->db->query($sql); if (!$resql) { From 71471a054d3c86f49afd9985928651bf6b79d47d Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 1 Sep 2020 16:53:42 +0200 Subject: [PATCH 35/86] Loaded the required translations --- htdocs/core/class/commonobject.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0d0a81a5192..a088ae6beb9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1297,6 +1297,8 @@ abstract class CommonObject // phpcs:enable global $langs, $conf; + $langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket')); + $tab = array(); $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; From 8a5a171cf818200bcd154514964070781c96089a Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 1 Sep 2020 16:59:40 +0200 Subject: [PATCH 36/86] Added agenda translation --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a088ae6beb9..3380fd2b979 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1297,7 +1297,7 @@ abstract class CommonObject // phpcs:enable global $langs, $conf; - $langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket')); + $langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket', 'agenda')); $tab = array(); From 47eee354f86aadb7b9fd954b51365821a1417bd5 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Tue, 1 Sep 2020 19:27:51 +0100 Subject: [PATCH 37/86] new : option to hide complementary actions --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index f2cb8c440c2..63da0be8677 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -854,7 +854,7 @@ if ($rowid > 0) { print '">'; // Complementary action - if (!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) { + if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { $company = new Societe($db); if ($object->fk_soc) { $result = $company->fetch($object->fk_soc); From ad4cdce92bd99416658ee008e9385836b202d851 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 21:18:21 +0200 Subject: [PATCH 38/86] Doc --- SECURITY.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 1189b6abe06..ac9ccbc677f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -62,12 +62,12 @@ No vulnerability disclosure, including partial is allowed for the moment. ## Scope for qualified vulnerabilities -ONLY vulnerabilities discovered when the following setup is used are accepted: +ONLY vulnerabilities discovered, when the following setup on tested platform is used, are accepted: * $dolibarr_main_prod must be 1 into conf.php * $dolibarr_nocsrfcheck must not be set to 0 (should be 1 by default) into conf.php -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be switched soon to 1 by default) -* ONLY security reports on "stable" modules are allowed (troubles into experimental and developement modules are not accepted). +* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be hard switched soon to 1 by default) +* ONLY security reports on "stable" modules are allowed (troubles into "experimental" and "developement" modules are not accepted). Scope is the web application (back office) and the APIs. @@ -84,6 +84,8 @@ Scope is the web application (back office) and the APIs. * CORS with real security impact * Horizontal and vertical privilege escalation * "HTTP Host Header" XSS +* Software version disclosure (for non admin users only) +* Stack traces or path disclosure (for non admin users only) ## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting @@ -93,8 +95,6 @@ Scope is the web application (back office) and the APIs. * Mixed content warnings * Denial of Service attacks * Clickjacking/UI redressing -* Software version disclosure -* Stack traces or path disclosure * Physical or social engineering attempts * Recently disclosed 0-day vulnerabilities * Presence of autocomplete attribute on web forms @@ -104,5 +104,7 @@ Scope is the web application (back office) and the APIs. * Missing security-related HTTP headers which do not lead directly to a vulnerability * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) -* Reports on features flagged as experimental +* Reports on features flagged as "experimental" or "development" +* Software version disclosure when logged user is admin +* Stack traces or path disclosure when logged user is admin From 8e02d39cb3e820e7bd0f6a45267215836435d66f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 22:44:03 +0200 Subject: [PATCH 39/86] Fix prefill of end date when event type is rendez-vous --- htdocs/comm/action/card.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 994613db8b1..330b8252010 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -918,9 +918,11 @@ if ($action == 'create') // Date end $datef = ($datef ? $datef : $object->datef); if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); - if (empty($datef) && !empty($datep) && !empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS)) + if (empty($datef) && !empty($datep)) { - $datef = dol_time_plus_duree($datep, $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS, 'h'); + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { + $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); + } } print ''; + print '
'; + print '
'; + print '

'; print '
'.$langs->trans("DraftSuppliersOrders").($num ? ''.$num.'' : '').'
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { From 619a9a367900ee035fdf21228c9e7343b7684e1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 22:53:49 +0200 Subject: [PATCH 40/86] Look and feel v13 --- htdocs/comm/action/card.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 330b8252010..f51da1cb259 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1175,13 +1175,14 @@ if ($action == 'create') if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) { //checkbox create reminder - print '
'; - print '
'.$langs->trans("AddReminder").'
'; From e4557b3dd3b2df98bfa14f7025cb0d9d294ec6a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Sep 2020 23:04:29 +0200 Subject: [PATCH 41/86] Responsive --- htdocs/comm/action/card.php | 45 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f51da1cb259..2dbbbd28084 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -904,33 +904,48 @@ if ($action == 'create') // Full day print ''; - // Date start - $datep = ($datep ? $datep : $object->datep); - if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); - print ''; + print '     -     '; + //print ' - '; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + } else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + } + print ''; // Date end - $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); - if (empty($datef) && !empty($datep)) - { - if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { - $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); - } - } - print ''; + print ''; + print '';*/ // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); From fb88c68ddba08d45955cb5e7d94c3fab66d04c61 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Sep 2020 05:15:58 +0200 Subject: [PATCH 42/86] New Accountancy - Balance - Move to getNomUrl on accounting account --- htdocs/accountancy/bookkeeping/balance.php | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 4de2be6fcbb..059e1eb57b1 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2019 Alexandre Spangaro + * Copyright (C) 2016-2020 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -31,6 +31,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -244,7 +245,7 @@ if ($action != 'export_csv') print '
'.$langs->trans("EventOnFullDay").'
'.$langs->trans("DateActionStart").''; + $datep = ($datep ? $datep : $object->datep); + if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); + $datef = ($datef ? $datef : $object->datef); + if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); + if (empty($datef) && !empty($datep)) + { + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { + $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); + } + } + + // Date start + print '
'; + print ''.$langs->trans("DateActionStart").''; + print ' - '; + print ''.$langs->trans("DateActionEnd").''; + print ''; if (GETPOST("afaire") == 1) { print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" } else { print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); } - print '
'.$langs->trans("DateActionEnd").''; + /*print '
'; + print ''.$langs->trans("DateActionEnd").''; + print ''; if (GETPOST("afaire") == 1) { print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); } else { print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); } - print '
'; print ''; - print ''; print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); @@ -274,6 +274,8 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; + $accountingaccountstatic = new AccountingAccount($db); + $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; $resql = $db->query($sql); @@ -286,12 +288,18 @@ if ($action != 'export_csv') foreach ($object->lines as $line) { + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } + $link = ''; $total_debit += $line->debit; $total_credit += $line->credit; - $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); - if (empty($description)) { + if (empty($accountingaccountstatic->account_number)) { $link = ''.img_edit_add().''; } print ''; @@ -303,7 +311,7 @@ if ($action != 'export_csv') // Show subtotal per accounting account if ($displayed_account != "") { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -313,7 +321,7 @@ if ($action != 'export_csv') // Show first line of a break print ''; - print ''; + print ''; print ''; $displayed_account = $root_account_description; @@ -321,10 +329,9 @@ if ($action != 'export_csv') $sous_total_credit = 0; } } - // $object->get_compte_racine($line->numero_compte); - print ''; - print ''; + // $object->get_compte_racine($line->numero_compte); + print ''; print ''; print ''; print ''; @@ -340,12 +347,12 @@ if ($action != 'export_csv') if (!empty($show_subgroup)) { - print ''; + print ''; print "\n"; print ''; } - print ''; + print ''; print "\n"; print ''; From 7b91c8efc8a886372e34285c6d244a07de235ff9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 2 Sep 2020 09:58:55 +0200 Subject: [PATCH 43/86] Event Reminder : Add "Default Mail Model" to select Mail Model --- htdocs/comm/action/card.php | 2 +- htdocs/core/class/html.form.class.php | 3 ++- htdocs/langs/en_US/main.lang | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 2dbbbd28084..813494fbad5 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1221,7 +1221,7 @@ if ($action == 'create') //Mail Model print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 153f1cdbae2..0544fd25bad 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7979,7 +7979,7 @@ class Form * @param string $modelType Model type * @return string HTML select string */ - public function selectModelMail($prefix, $modelType = '') + public function selectModelMail($prefix, $modelType = '', $default = 0) { global $langs, $db, $user; @@ -7992,6 +7992,7 @@ class Form $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); if ($result > 0) { + if($default) $TModels[0] = $langs->trans('DefaultMailModel'); foreach ($formmail->lines_model as $model){ $TModels[$model->id] = $model->label; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 331d81a90c8..100856b3fa7 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1083,4 +1083,5 @@ CREATEInDolibarr=Record %s created MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated -APPROVEDInDolibarr=Record %s approved \ No newline at end of file +APPROVEDInDolibarr=Record %s approved +DefaultMailModel=Default Mail Model \ No newline at end of file From 27c754e6c8be24b5bf1ae5e9329290089cfd9a14 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 2 Sep 2020 15:33:18 +0200 Subject: [PATCH 44/86] NEW add send context for ticket --- htdocs/admin/mails_ticket.php | 574 ++++++++++++++++++++++++++ htdocs/core/class/CMailFile.class.php | 30 +- htdocs/core/lib/admin.lib.php | 8 + htdocs/ticket/class/ticket.class.php | 2 +- 4 files changed, 602 insertions(+), 12 deletions(-) create mode 100644 htdocs/admin/mails_ticket.php diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php new file mode 100644 index 00000000000..0a452d109ce --- /dev/null +++ b/htdocs/admin/mails_ticket.php @@ -0,0 +1,574 @@ + + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016 Jonathan TISSEAU + * + * 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/admin/mails_ticket.php + * \brief Page to setup mails for ticket + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors')); + +$action = GETPOST('action', 'alpha'); + +if (!$user->admin) accessforbidden(); + +$usersignature = $user->signature; +// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. +if ($action == 'test' || $action == 'send') +{ + $usersignature = dol_string_nohtmltag($usersignature); +} + +$substitutionarrayfortest = array( +'__LOGIN__' => $user->login, +'__ID__' => 'TESTIdRecord', +'__EMAIL__' => 'TESTEMail', +'__LASTNAME__' => 'TESTLastname', +'__FIRSTNAME__' => 'TESTFirstname', +'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), +//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet +); +complete_substitutions_array($substitutionarrayfortest, $langs); + + + +/* + * Actions + */ + +if ($action == 'update' && empty($_POST["cancel"])) +{ + // Send mode parameters + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity); + + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); + exit; +} + + +// Actions to send emails +$id = 0; +$actiontypecode = ''; // Not an event for agenda +$triggersendname = ''; // Disable triggers +$paramname = 'id'; +$mode = 'emailfortest'; +$trackid = (($action == 'testhtml') ? "testhtml" : "test"); +$sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket +include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + +if ($action == 'presend' && GETPOST('trackid') == 'test') $action = 'test'; +if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action = 'testhtml'; + + + + +/* + * View + */ + +$form = new Form($db); + +$linuxlike = 1; +if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; +if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; + +if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default'; +$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get('smtp_port'); +if (!$port) $port = 25; +$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get('SMTP'); +if (!$server) $server = '127.0.0.1'; + + +$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; +llxHeader('', $langs->trans("Setup"), $wikihelp); + +print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup'); + +$head = email_admin_prepare_head(); + +// List of sending methods +$listofmethods = array(); +$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup'); +$listofmethods['mail'] = 'PHP mail function'; +//$listofmethods['simplemail']='Simplemail class'; +$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; +$listofmethods['swiftmailer'] = 'Swift Mailer socket library'; + + +if ($action == 'edit') +{ + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'common_ticket', '', -1); + + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; + + + clearstatcache(); + + print '
'; + print ''; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); print ' '; @@ -260,7 +261,6 @@ if ($action != 'export_csv') print '
'.$langs->trans("SubTotal").':'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).'
'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'
'.length_accountg($line->numero_compte).''.$description.''.$accounting_account.''.price($opening_balances["'".$line->numero_compte."'"]).''.price($line->debit).''.price($line->credit).'
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).'
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).'
'.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).'
'.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).'
'.$langs->trans("EMailTemplates").''; - print $form->selectModelMail('actioncommsend', 'actioncomm_send'); + print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1); print '
'; + print ''; + + // Method + + print ''; + + // Host server + + print ''; + + // Port + + print ''; + + // ID + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) + { + $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : ''); + print ''; + } + + // PW + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) + { + $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : ''); + print ''; + } + + // TLS + + print ''; + + // STARTTLS + + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; + + // SuperAdministrator access only + if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + { + print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET); + } else { + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; + if (empty($text)) $text = $langs->trans("Undefined"); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); + print ''; + } + print '
'; + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } else { + $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ''); + $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); + if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); + else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); + print ''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; + } else { + $text = !empty($mainserver) ? $mainserver : $smtpserver; + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); + print ''; + } + } + print '
'; + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } else { + $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ''); + $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); + if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); + else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); + print ''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; + } else { + $text = (!empty($mainport) ? $mainport : $smtpport); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); + print ''; + } + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + } else { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1, 'superadmin'); + print ''; + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + } else { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1, 'superadmin'); + print ''; + } + print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; +} else { + dol_fiche_head($head, 'common_ticket', '', -1); + + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; + + print ''; + print ''; + + // Method + print ''; + + if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') + { + // Host server + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) + { + print ''; + } else { + print ''; + } + + // Port + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) + { + print ''; + } else { + print ''; + } + + // SMTPS ID + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) + { + print ''; + } + + // SMTPS PW + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) + { + print ''; + } + + // TLS + print ''; + + // STARTTLS + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; + if (empty($text)) $text = $langs->trans("Undefined").img_warning(); + print $text; + print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'; + + dol_fiche_end(); + + + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* + // Warning 1 + if ($linuxlike) + { + $sendmailoption=ini_get('mail.force_extra_parameters'); + if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption)) + { + print info_admin($langs->trans("SendmailOptionNotComplete")); + } + }*/ + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } + + + // Buttons for actions + + print '
'; + + print ''.$langs->trans("Modify").''; + + if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') + { + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) + { + if (function_exists('fsockopen') && $port && $server) + { + print ''.$langs->trans("DoTestServerAvailability").''; + } + } else { + print ''.$langs->trans("DoTestServerAvailability").''; + } + + print ''.$langs->trans("DoTestSend").''; + + if (!empty($conf->fckeditor->enabled)) + { + print ''.$langs->trans("DoTestSendHTML").''; + } + } + + print '
'; + + + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) + { + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); + } + + // Run the test to connect + if ($action == 'testconnect') + { + print load_fiche_titre($langs->trans("DoTestServerAvailability")); + + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); + + $result = $mail->check_server_port($server, $port); + if ($result) print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; + else { + $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); + + if ($mail->error) { + $errormsg .= ' - '.$mail->error; + } + + setEventMessages($errormsg, null, 'errors'); + } + print '
'; + } + + // Show email send test form + if ($action == 'test' || $action == 'testhtml') + { + print '
'; + print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); + + dol_fiche_head(''); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); + $formmail->withfromreadonly = 0; + $formmail->withsubstit = 0; + $formmail->withfrom = 1; + $formmail->witherrorsto = 1; + $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty + $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withtopicreadonly = 0; + $formmail->withfile = 2; + $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbodyreadonly = 0; + $formmail->withcancel = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0); + $formmail->ckeditortoolbar = 'dolibarr_mailings'; + // Tableau des substitutions + $formmail->substit = $substitutionarrayfortest; + // Tableau des parametres complementaires du post + $formmail->param["action"] = "send"; + $formmail->param["models"] = "body"; + $formmail->param["mailid"] = 0; + $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; + + // Init list of files + if (GETPOST("mode") == 'init') + { + $formmail->clear_attached_files(); + } + + print $formmail->get_form('addfile', 'removefile'); + + dol_fiche_end(); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c005ba77f3c..a98846a6309 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -168,9 +168,13 @@ class CMailFile // Define this->sendmode $this->sendmode = ''; - if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') - { - $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE_EMAILING; + if (!empty($this->sendcontext)) { + $smtpContextKey = strtoupper($this->sendcontext); + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { + $this->sendmode = $smtpContextSendMode; + } } if (empty($this->sendmode)) $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($this->sendmode)) $this->sendmode = 'mail'; @@ -635,14 +639,18 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; - if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') - { - $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING'; - $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_EMAILING'; - $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_EMAILING'; - $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_EMAILING'; - $keyfortls = 'MAIN_MAIL_EMAIL_TLS_EMAILING'; - $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; + if (!empty($this->sendcontext)) { + $smtpContextKey = strtoupper($this->sendcontext); + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; + } } // Action according to choosed sending method diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 687e4ee4ffe..48314125bdc 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1769,6 +1769,14 @@ function email_admin_prepare_head() $head[$h][2] = 'common_emailing'; $h++; } + + if ($conf->ticket->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/admin/mails_ticket.php"; + $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv("Ticket")); + $head[$h][2] = 'common_ticket'; + $h++; + } } $head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2d5fd47cd82..c9e7c4cc416 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2781,7 +2781,7 @@ class Ticket extends CommonObject } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $trackid = "tic".$this->id; - $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid); + $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket'); if ($mailfile->error) { setEventMessages($mailfile->error, null, 'errors'); } else { From cd952f742724f71e0ac0f9e2136bc54f7065eb7e Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 2 Sep 2020 16:24:22 +0200 Subject: [PATCH 45/86] Fix and factor fetch combination price level --- .../class/ProductCombination.class.php | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 50c0dedaced..56636ce4379 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -165,18 +165,12 @@ class ProductCombination /** * for auto retrocompatibility with last behavior */ - $productCombinationLevel = new ProductCombinationLevel($this->db); - $productCombinationLevel->fk_price_level = intval($fk_price_level); - $productCombinationLevel->fk_product_attribute_combination = $this->id; - $productCombinationLevel->variation_price = $this->variation_price; - $productCombinationLevel->variation_price_percentage = $this->variation_price_percentage; - if ($fk_price_level>0){ - $combination_price_levels[$fk_price_level] = $productCombinationLevel; + $combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level); } else { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ - $combination_price_levels[$i] = $productCombinationLevel; + $combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i); } } } @@ -1211,4 +1205,25 @@ class ProductCombinationLevel return $res ? 1 : -1; } + + + /** + * Create new Product Combination Price level from Parent + * + * @param DoliDB $db + * @param ProductCombination $productCombination + * @param int $fkPriceLevel + * + * @return ProductCombinationLevel + */ + public static function createFromParent(DoliDB $db, ProductCombination $productCombination, $fkPriceLevel) + { + $productCombinationLevel = new self($db); + $productCombinationLevel->fk_price_level = $fkPriceLevel; + $productCombinationLevel->fk_product_attribute_combination = $productCombination->id; + $productCombinationLevel->variation_price = $productCombination->variation_price; + $productCombinationLevel->variation_price_percentage = $productCombination->variation_price_percentage; + + return $productCombinationLevel; + } } From 2a4f0fc034d9e2100b76e39bca5f2dc3ac69204b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 16:37:02 +0200 Subject: [PATCH 46/86] Fix backto link --- htdocs/comm/action/card.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 2dbbbd28084..6bf3ccc14c2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1253,9 +1253,13 @@ if ($action == 'create') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + if (empty($backtopage)) { + print ''; + } else { + print ''; + } print '
'; print ""; From de3e818ccf53eb35997b95478fe02a4e90c4d57b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 18:08:08 +0200 Subject: [PATCH 47/86] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0544fd25bad..996fcc52912 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7992,7 +7992,7 @@ class Form $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); if ($result > 0) { - if($default) $TModels[0] = $langs->trans('DefaultMailModel'); + if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); foreach ($formmail->lines_model as $model){ $TModels[$model->id] = $model->label; } From a984c8e969a5aa2a3d8c5f871721825131f1975d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 18:57:56 +0200 Subject: [PATCH 48/86] Use english --- htdocs/comm/propal/class/propal.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6b9e66a9225..e51f7952003 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2504,12 +2504,12 @@ class Propal extends CommonObject * Close the commercial proposal * * @param User $user Object user that close - * @param int $statut Statut + * @param int $status Status * @param string $note Complete private note with this note * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - public function cloture($user, $statut, $note = "", $notrigger = 0) + public function cloture($user, $status, $note = "", $notrigger = 0) { global $langs, $conf; @@ -2521,7 +2521,7 @@ class Propal extends CommonObject $newprivatenote = dol_concatdesc($this->note_private, $note); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); @@ -2530,7 +2530,7 @@ class Propal extends CommonObject $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf; $triggerName = 'PROPAL_CLOSE_REFUSED'; - if ($statut == self::STATUS_SIGNED) + if ($status == self::STATUS_SIGNED) { $triggerName = 'PROPAL_CLOSE_SIGNED'; $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf; @@ -2547,7 +2547,7 @@ class Propal extends CommonObject return -2; } } - if ($statut == self::STATUS_BILLED) // Why this ? + if ($status == self::STATUS_BILLED) // Why this ? { $triggerName = 'PROPAL_CLASSIFY_BILLED'; } @@ -2569,7 +2569,7 @@ class Propal extends CommonObject if (!$error) { $this->oldcopy = clone $this; - $this->statut = $statut; + $this->statut = $status; $this->date_cloture = $now; $this->note_private = $newprivatenote; } From a58dcc38865843c395fc9102527e0971f0eb1828 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 19:10:07 +0200 Subject: [PATCH 49/86] Doc --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e51f7952003..e0b645f6faf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2547,7 +2547,7 @@ class Propal extends CommonObject return -2; } } - if ($status == self::STATUS_BILLED) // Why this ? + if ($status == self::STATUS_BILLED) // ->cloture() can also be called when we set it to billed, after setting it to signed { $triggerName = 'PROPAL_CLASSIFY_BILLED'; } From 80f824569a0227d51bef02b15844051dc3c16903 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 19:15:03 +0200 Subject: [PATCH 50/86] Use english --- htdocs/comm/propal/card.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 86f073d2c70..90ab0605c68 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -603,7 +603,7 @@ if (empty($reshook)) { $db->begin(); - $result = $object->cloture($user, Propal::STATUS_BILLED, ''); + $result = $object->cloture($user, $object::STATUS_BILLED, ''); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -617,13 +617,13 @@ if (empty($reshook)) $db->rollback(); } } // Close proposal - elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { + elseif ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) { if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); - $action = 'statut'; + $action = 'closeas'; } else { // prevent browser refresh from closing proposal several times - if ($object->statut == Propal::STATUS_VALIDATED) + if ($object->statut == $object::STATUS_VALIDATED) { $db->begin(); @@ -1824,11 +1824,11 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if ($action == 'statut') + if ($action == 'closeas') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select', 'name' => 'statut', 'label' => ''.$langs->trans("CloseAs").'', 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'select', 'name' => 'statut', 'label' => ''.$langs->trans("CloseAs").'', 'values' => array(2=>$object->LibStatut($object::STATUS_SIGNED), 3=>$object->LibStatut($object::STATUS_NOTSIGNED))), array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); @@ -1841,7 +1841,7 @@ if ($action == 'create') )); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250); } // Confirm delete elseif ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); @@ -2483,9 +2483,9 @@ if ($action == 'create') } } - // Set accepted/refused + // Close as accepted/refused if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; print '>'.$langs->trans('SetAcceptedRefused').''; } From 4dca1929e058d613980403edf323c93058ea6eb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 19:19:47 +0200 Subject: [PATCH 51/86] Can close a recruitment job --- htdocs/core/class/commonobject.class.php | 6 ++ htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/propal.lang | 1 - .../class/recruitmentjobposition.class.php | 95 ++++++++++++++++++- .../recruitmentjobposition_card.php | 70 ++++++++++---- 5 files changed, 155 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index be4b48be401..c5d72ee1ba1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7645,6 +7645,12 @@ abstract class CommonObject $this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); } + // If value is null and there is a default value for field + if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && (!isset($values[$key]) || $values[$key] === 'NULL') && !is_null($this->fields[$key]['default'])) + { + $values[$key] = $this->fields[$key]['default']; + } + // If field is an implicit foreign key field if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { if (isset($this->fields[$key]['default'])) $values[$key] = $this->fields[$key]['default']; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 331d81a90c8..e27af882c51 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -155,6 +155,7 @@ RemoveLink=Remove link AddToDraft=Add to draft Update=Update Close=Close +CloseAs=Set status to CloseBox=Remove widget from your dashboard Confirm=Confirm ConfirmSendCardByMail=Do you really want to send the content of this card by mail to %s? diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 273996ab1b1..c68574d9ae2 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -47,7 +47,6 @@ SendPropalByMail=Send commercial proposal by mail DatePropal=Date of proposal DateEndPropal=Validity ending date ValidityDuration=Validity duration -CloseAs=Set status to SetAcceptedRefused=Set accepted/refused ErrorPropalNotFound=Propal %s not found AddToDraftProposals=Add to draft proposal diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index d6a8c62e000..e7fb5ba1e48 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -122,7 +122,7 @@ class RecruitmentJobPosition extends CommonObject 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>0,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '3'=>'Recruited', '9'=>'Canceled'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>5, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '3'=>'Recruited', '9'=>'Canceled'),), ); public $rowid; public $ref; @@ -660,6 +660,99 @@ class RecruitmentJobPosition extends CommonObject return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'RECRUITMENTJOBPOSITION_CLOSE'); } + /** + * Close the commercial proposal + * + * @param User $user Object user that close + * @param int $status Statut + * @param string $note Complete private note with this note + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function cloture($user, $status, $note = "", $notrigger = 0) + { + global $langs, $conf; + + $error = 0; + $now = dol_now(); + + $this->db->begin(); + + $newprivatenote = dol_concatdesc($this->note_private, $note); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET status = ".$status.", note_private = '".$this->db->escape($newprivatenote)."'"; + //$sql .= ", date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $resql = $this->db->query($sql); + if ($resql) + { + $modelpdf = $this->modelpdf; + $triggerName = 'PROPAL_CLOSE_REFUSED'; + + if ($status == self::STATUS_RECRUITED) + { + $triggerName = 'RECRUITMENTJOB_CLOSE_RECRUITED'; + $modelpdf = $this->modelpdf; + + if ($result < 0) + { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs); + } + + if (!$error) + { + $this->oldcopy = clone $this; + $this->status = $status; + $this->date_cloture = $now; + $this->note_private = $newprivatenote; + } + + if (!$notrigger && empty($error)) + { + // Call trigger + $result = $this->call_trigger($triggerName, $user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->status = $this->oldcopy->status; + $this->date_cloture = $this->oldcopy->date_cloture; + $this->note_private = $this->oldcopy->note_private; + + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + /** * Set back to validated status * diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index bdc1fe24742..638bc9e4cef 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -109,6 +109,8 @@ $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1]; +$usercanclose = $permissiontoadd; + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; @@ -163,6 +165,32 @@ if (empty($reshook)) { $object->setProject(GETPOST('projectid', 'int')); } + if ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) { + if (!(GETPOST('status', 'int') > 0)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); + $action = 'closeas'; + } else { + // prevent browser refresh from closing proposal several times + if ($object->status == $object::STATUS_VALIDATED) + { + $db->begin(); + + $result = $object->cloture($user, GETPOST('status', 'int'), GETPOST('note_private', 'none')); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + + if (!$error) + { + $db->commit(); + } else { + $db->rollback(); + } + } + } + } // Actions to send emails $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL'; @@ -286,22 +314,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formquestion = array(); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - - // Confirmation of action xxxx - if ($action == 'xxx') + if ($action == 'closeas') { - $formquestion = array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + //Form to close proposal (signed or not) $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'select', 'name' => 'status', 'label' => ''.$langs->trans("CloseAs").'', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + + /*if (!empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $formquestion = array_merge($formquestion, array( + array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), + )); + }*/ + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_closeas', $formquestion, '', 1, 250); } // Call Hook formConfirm @@ -482,6 +512,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } + // Close as recruited/canceled + if ($object->status == $object::STATUS_VALIDATED) { + if ($usercanclose) { + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print '>'.$langs->trans('Close').''; + } else { + print ''.$langs->trans('Close').''; + } + } + // Clone if ($permissiontoadd) { print ''.$langs->trans("ToClone").''."\n"; @@ -497,9 +537,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Cancel").''."\n"; - } else { + if ($object->status == $object::STATUS_CANCELED) { print ''.$langs->trans("Re-Open").''."\n"; } } From ed743c9dbba86afb2d9daa68b8e1791efa350871 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 21:39:22 +0200 Subject: [PATCH 52/86] Fix phpcs More secured sendEmailsReminder() --- htdocs/comm/action/class/actioncomm.class.php | 110 +++++++++--------- htdocs/core/class/html.form.class.php | 1 + htdocs/theme/md/badges.inc.php | 4 +- 3 files changed, 60 insertions(+), 55 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fd41a9eadf4..6b5f19fa64c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1965,6 +1965,8 @@ class ActionComm extends CommonObject $error = 0; $this->output = ''; $this->error = ''; + $nbMailSend = 0; + $errorsMsg = array(); if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. { @@ -2005,68 +2007,68 @@ class ActionComm extends CommonObject if (!$error) { - //Select email template - $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); + //Select email template + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); - // Load event - $res = $this->fetch($actionCommReminder->fk_actioncomm); - if ($res > 0) - { - // PREPARE EMAIL + // Load event + $res = $this->fetch($actionCommReminder->fk_actioncomm); + if ($res > 0) + { + // PREPARE EMAIL - // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); - complete_substitutions_array($substitutionarray, $langs, $this); + complete_substitutions_array($substitutionarray, $langs, $this); - // Content - $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); + // Content + $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); - //Topic - $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); + //Topic + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); - // Recipient - $recipient = new User($this->db); - $res = $recipient->fetch($actionCommReminder->fk_user); - if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; - else { - $errorsMsg[] = "Failed to load recipient"; - $error++; - } + // Recipient + $recipient = new User($this->db); + $res = $recipient->fetch($actionCommReminder->fk_user); + if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; + else { + $errorsMsg[] = "Failed to load recipient"; + $error++; + } - // Sender - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - if (empty($from)) { - $errorsMsg[] = "Failed to load recipient"; - $error++; - } + // Sender + $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + if (empty($from)) { + $errorsMsg[] = "Failed to load recipient"; + $error++; + } - // Errors Recipient - $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + // Errors Recipient + $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; - // Mail Creation - $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); - // Sending Mail - if ($cMailFile->sendfile()) - { - $actionCommReminder->status = $actionCommReminder::STATUS_DONE; - $res = $actionCommReminder->update($user); - if ($res < 0) - { - $errorsMsg[] = "Failed to update status of ActionComm Reminder"; - $error++; - } - else $nbMailSend++; - } - else { - $errorsMsg[] = $cMailFile->error.' : '.$to; - $error++; - } - } - else { - $error++; - } + // Sending Mail + if ($cMailFile->sendfile()) + { + $actionCommReminder->status = $actionCommReminder::STATUS_DONE; + $res = $actionCommReminder->update($user); + if ($res < 0) + { + $errorsMsg[] = "Failed to update status of ActionComm Reminder"; + //$error++; Do not add error here. + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + } else { + $nbMailSend++; + } + } else { + $errorsMsg[] = $cMailFile->error.' : '.$to; + $error++; + } + } else { + $error++; + } } } } else { @@ -2087,12 +2089,14 @@ class ActionComm extends CommonObject } if (!$error) { + $this->output = 'Nb of emails sent : '.$nbMailSend; $this->db->commit(); return 0; } else { $this->db->rollback(); - return (!empty($errorsMsg)) ? end($errorsMsg) : $error; + $this->error = (!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; + return $error; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 996fcc52912..a913a878251 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7977,6 +7977,7 @@ class Form * * @param string $prefix Prefix * @param string $modelType Model type + * @param int $default 1=Show also Default mail template * @return string HTML select string */ public function selectModelMail($prefix, $modelType = '', $default = 0) diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index 55bec9ce8f6..1ce2d912669 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -215,7 +215,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) { print "\n/* ".strtoupper($commentLabel)." */\n"; - + $thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName}; @@ -233,7 +233,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL if (in_array((string) $statusName, array('0', '5', '9'))) $thisBadgeTextColor = '#999999'; if (in_array((string) $statusName, array('6'))) $thisBadgeTextColor = '#777777'; - + print $cssPrefix.".badge-status".$statusName." {\n"; print " color: ".$thisBadgeTextColor." !important;\n"; if (in_array((string) $statusName, $TBadgeBorderOnly)) { From f642fc9ad96eee5c522af40b2840042c56396ae2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 21:40:17 +0200 Subject: [PATCH 53/86] Fix --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6b5f19fa64c..87f1aea95e4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2057,7 +2057,7 @@ class ActionComm extends CommonObject if ($res < 0) { $errorsMsg[] = "Failed to update status of ActionComm Reminder"; - //$error++; Do not add error here. + $error++; break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. } else { $nbMailSend++; From 31548c6fbb0e236be2d83afa0d8049ab6c1caf89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Sep 2020 21:42:29 +0200 Subject: [PATCH 54/86] Better error message --- htdocs/comm/action/class/actioncomm.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 87f1aea95e4..4f878f0cec4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2084,18 +2084,18 @@ class ActionComm extends CommonObject if (!$resql) { $errorsMsg[] = 'Failed to delete old reminders'; - $error ++; + //$error++; // If this fails, we must not rollback other SQL requests already done. Never mind. } } if (!$error) { $this->output = 'Nb of emails sent : '.$nbMailSend; - $this->db->commit(); + $this->db->commit(); return 0; } else { $this->db->rollback(); - $this->error = (!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; + $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; return $error; } From 853bacd545f65e09316c93f8d7604e36143a9fcf Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Sep 2020 23:43:36 +0200 Subject: [PATCH 55/86] New Accountancy Add predefined url in getNomUrl --- htdocs/accountancy/class/accountingaccount.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 43442fa0ca5..06e73a07d9d 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -448,9 +448,10 @@ class AccountingAccount extends CommonObject * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) + * @param int $targeturl 0=bookkeeping, 1=bookkeeping listbyaccount, 2=account card * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0) + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $targeturl = 0) { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -459,7 +460,13 @@ class AccountingAccount extends CommonObject $result = ''; - $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id; + if (empty($targeturl)) { + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + } elseif ($targeturl == 1) { + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + } elseif ($targeturl == 2) { + $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + } // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); From b3cd9688d5c30fbe9408ecce16c9aca7d06df3e6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Sep 2020 23:43:47 +0200 Subject: [PATCH 56/86] Typo --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 31b16b7fb65..65e44b86efc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -122,7 +122,7 @@ class FormFile $out .= ''; } - $out .= ''; + $out .= '
'; $out .= ''; if (!empty($options)) $out .= ''; From 197d03f9d9917eacba5e80aa2f0d9bf1dc535261 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 3 Sep 2020 09:23:10 +0200 Subject: [PATCH 57/86] FIX selectModelMail() : if default and no mail models select default model --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a913a878251..3daaf572ca6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7992,8 +7992,8 @@ class Form $formmail = new FormMail($db); $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); + if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); if ($result > 0) { - if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); foreach ($formmail->lines_model as $model){ $TModels[$model->id] = $model->label; } From 38da331a8bff996a94f1a938f494eff6e9edaef0 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 3 Sep 2020 10:41:42 +0200 Subject: [PATCH 58/86] Show number and clickable on warehouse area --- htdocs/product/stock/index.php | 117 ++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index fc43d5e8ce3..f144fe38a75 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2019 Nicolas ZABOURI +/* Copyright (C) 2003-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -19,9 +20,9 @@ */ /** - * \file htdocs/product/stock/index.php - * \ingroup stock - * \brief Home page of stock area + * \file htdocs/product/stock/index.php + * \ingroup stock + * \brief Home page of stock area */ require '../../main.inc.php'; @@ -60,22 +61,22 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - print '
'; - print ''; - print '
'; - print '
'.$options.'
'; - print ""; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'; - print $langs->trans("Warehouse").':

"; + print '
'; + print ''; + print '
'; + print ''; + print ""; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("Warehouse").':

"; } $max = 15; $sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; -$sql .= " WHERE e.statut in (0,1)"; +$sql .= " WHERE e.statut in (".Entrepot::STATUS_CLOSED.",".Entrepot::STATUS_OPEN_ALL.")"; $sql .= " AND e.entity IN (".getEntity('stock').")"; $sql .= $db->order('e.statut', 'DESC'); $sql .= $db->plimit($max + 1, 0); @@ -84,45 +85,55 @@ $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $db->num_rows($result); - $i = 0; + print '
'; + print ''; + print ''; + print ''; + print ''; - print '
'; - print '
'; + print $langs->trans("Warehouses").' '; + print ''; + // TODO: "search_status" on "/product/stock/list.php" currently only accept a single integer value + //print ''; + print ''.$num.''; + print ''; + print '
'; - print ''; + $i = 0; + if ($num) + { + while ($i < min($max, $num)) + { + $objp = $db->fetch_object($result); - if ($num) - { - while ($i < min($max, $num)) - { - $objp = $db->fetch_object($result); + $warehouse->id = $objp->rowid; + $warehouse->statut = $objp->status; + $warehouse->label = $objp->label; + $warehouse->lieu = $objp->lieu; - $warehouse->id = $objp->rowid; - $warehouse->statut = $objp->status; - $warehouse->label = $objp->label; - $warehouse->lieu = $objp->lieu; + print ''; + print ''."\n"; + print ''; + print "\n"; + $i++; + } + $db->free($result); + } else { + print ''; + } + if ($num > $max) { + print ''; + } - print ''; - print ''."\n"; - print ''; - print "\n"; - $i++; - } - $db->free($result); - } - if ($num > $max) { - print ''; - } - - print "
'.$langs->trans("Warehouses").'
'; + print $warehouse->getNomUrl(1); + print ''; + print $warehouse->getLibStatut(5); + print '
'.$langs->trans("None").'
'.$langs->trans("More").'...
'; - print $warehouse->getNomUrl(1); - print ''; - print $warehouse->getLibStatut(5); - print '
'.$langs->trans("More").'...
"; - print '
'; + print "
"; + print ''; } else { - dol_print_error($db); + dol_print_error($db); } @@ -141,7 +152,7 @@ $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE m.fk_product = p.rowid"; $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = ".Product::TYPE_PRODUCT; $sql .= $db->order("datem", "DESC"); $sql .= $db->plimit($max, 0); @@ -151,7 +162,7 @@ if ($resql) { $num = $db->num_rows($resql); - print '
'; + print '
'; print ''; print ""; print ''; @@ -206,7 +217,7 @@ if ($resql) $db->free($resql); print "
'.$langs->trans("LastMovements", min($num, $max)).'
"; - print '
'; + print '
'; } else { dol_print_error($db); } From 5af1eff2d91ca055da82e2f95d6d0fe979ce8a7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 10:46:46 +0200 Subject: [PATCH 59/86] Fix phpcs --- htdocs/comm/action/class/actioncomm.class.php | 1 - htdocs/expensereport/card.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4f878f0cec4..37ddf2f43ae 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2098,7 +2098,6 @@ class ActionComm extends CommonObject $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; return $error; } - } /** diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f5348bb4261..d4f09f793bc 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2195,10 +2195,10 @@ if ($action == 'create') { print ''; - print 'rowid.'">'; + print 'rowid.'">'; print img_edit(); print '   '; - print 'rowid.'">'; + print 'rowid.'">'; print img_delete(); print ''; From 77d15c9382fd5c8121765e98eb3455ef02c9b731 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 11:34:20 +0200 Subject: [PATCH 60/86] Fix long name overlap date --- .../modules/expensereport/doc/pdf_standard.modules.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 5458283b492..301ea9fa5de 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -796,7 +796,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); - // Informations for trip (dates and users workflow) + // Informations for expense report (dates and users workflow) if ($object->fk_user_author > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_author); @@ -804,7 +804,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', 10); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy += 5; + $posy = $pdf->GetY() + 1; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); } @@ -822,8 +822,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse, "day", false, $outputlangs), 0, 'L'); } - } elseif ($object->fk_statut == 4) - { + } elseif ($object->fk_statut == 4) { if ($object->fk_user_cancel > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_cancel); $posy += 6; From 8f37f6647022b4c288c542845caddbe54a512a53 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 3 Sep 2020 11:36:11 +0200 Subject: [PATCH 61/86] Show number and allow click on payment area --- htdocs/compta/index.php | 66 +++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 3121aeffb17..fda16cea665 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Marcos García * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -148,7 +149,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -175,10 +176,18 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $num = $db->num_rows($resql); - print '
'; + print '
'; print ''; + print ''; - print ''; + print ''; + print ''; + if ($num) { $companystatic = new Societe($db); @@ -244,7 +253,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').')'; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -258,10 +267,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU { $num = $db->num_rows($resql); - print '
'; + print '
'; print '
'.$langs->trans("CustomersDraftInvoices").($num ? ''.$num.'' : '').'
'; + print $langs->trans("CustomersDraftInvoices").' '; + print ''; + print ''.$num.''; + print ''; + print '
'; + print ''; - print ''; + print ''; + print ''; + if ($num) { $companystatic = new Societe($db); @@ -709,7 +726,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $sql .= " AND c.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND c.fk_soc = ".$socid; - $sql .= " AND c.fk_statut = 3"; + $sql .= " AND c.fk_statut = ".Commande::STATUS_CLOSED; $sql .= " AND c.facture = 0"; // Add where from hooks $parameters = array(); @@ -729,8 +746,15 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print '
'; print '
'.$langs->trans("SuppliersDraftInvoices").($num ? ''.$num.'' : '').'
'; + print $langs->trans("SuppliersDraftInvoices").' '; + print ''; + print ''.$num.''; + print ''; + print '
'; + print ""; - print ''; + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; @@ -822,7 +846,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.entity IN (".getEntity('invoice').')'; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -843,7 +867,15 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; print '
'.$langs->trans("OrdersDeliveredToBill").' '.$num.''; + print $langs->trans("OrdersDeliveredToBill").' '; + print ''; + print ''.$num.''; + print ''; + print ''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("ToBill").'
'; - print ''; + + print ''; + print ''; + print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; @@ -954,7 +986,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= " WHERE s.rowid = ff.fk_soc"; $sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.paye = 0"; - $sql .= " AND ff.fk_statut = 1"; + $sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND ff.fk_soc = ".$socid; // Add where from hooks @@ -973,7 +1005,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print '
'; print '
'.$langs->trans("BillsCustomersUnpaid", $num).' '.$num.'
'; + print $langs->trans("BillsCustomersUnpaid", $num).' '; + print ''; + print ''.$num.''; + print ''; + print ''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").'
'; - print ''; + + print ''; + print ''; + print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; From 06e8e62d3875d34090aadb9bd2089e88f7f16a09 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Sep 2020 09:49:35 +0000 Subject: [PATCH 62/86] Fixing style errors. --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index fda16cea665..e487cf5746e 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1010,7 +1010,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; - print ''; + print ''; print ''; if ($num) { @@ -408,21 +411,27 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm $objp = $db->fetch_object($resql); $staticrecruitmentcandidature->id=$objp->rowid; $staticrecruitmentcandidature->ref=$objp->ref; + $staticrecruitmentcandidature->email=$objp->email; $staticrecruitmentcandidature->status = $objp->status; $staticrecruitmentcandidature->date_creation = $objp->date_creation; + $staticrecruitmentcandidature->firstname = $objp->firstname; + $staticrecruitmentcandidature->lastname = $objp->lastname; print ''; print ''; print '"; print '"; + print '"; print ''; $i++; } $db->free($resql); } else { - print ''; + print ''; } print "
'.$langs->trans("BillsSuppliersUnpaid", $num).' '.$num.'
'; + print $langs->trans("BillsSuppliersUnpaid", $num).' '; + print ''; + // TODO: "impayees.php" looks very outdatetd and should be set to deprecated or directly remove in the next version + // + print ''.$num.''; + print ''; + print ''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''; print $langs->trans("BillsSuppliersUnpaid", $num).' '; print ''; - // TODO: "impayees.php" looks very outdatetd and should be set to deprecated or directly remove in the next version + // TODO: "impayees.php" looks very outdatetd and should be set to deprecated or directly remove in the next version // print ''.$num.''; print ''; From 1a33cd91c98ce4fb6617fec6f19db930a4463088 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 12:20:20 +0200 Subject: [PATCH 63/86] Update index.php --- htdocs/compta/index.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e487cf5746e..a313f47cc13 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -33,12 +33,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (!empty($conf->commande->enabled)) - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->commande->enabled)) - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (!empty($conf->tax->enabled)) - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; // L'espace compta/treso doit toujours etre actif car c'est un espace partage // par de nombreux modules (banque, facture, commande a facturer, etc...) independamment From 87113a77b448a748757ab9487bb229d1f6ee04e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 12:32:51 +0200 Subject: [PATCH 64/86] Update accountingaccount.class.php --- htdocs/accountancy/class/accountingaccount.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 06e73a07d9d..7cb30a74bc6 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -448,10 +448,10 @@ class AccountingAccount extends CommonObject * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) - * @param int $targeturl 0=bookkeeping, 1=bookkeeping listbyaccount, 2=account card + * @param int $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard' * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $targeturl = 0) + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -460,11 +460,11 @@ class AccountingAccount extends CommonObject $result = ''; - if (empty($targeturl)) { + if (empty($option)) { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; - } elseif ($targeturl == 1) { + } elseif ($option == 'bookkeepinglistbyaccount') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; - } elseif ($targeturl == 2) { + } elseif ($option == 'accountcard') { $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; } From 1d3c54dd64bc86e9bcd7014400098ac9989d8ab7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 12:36:57 +0200 Subject: [PATCH 65/86] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 56636ce4379..e62d0e3760a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1210,9 +1210,9 @@ class ProductCombinationLevel /** * Create new Product Combination Price level from Parent * - * @param DoliDB $db - * @param ProductCombination $productCombination - * @param int $fkPriceLevel + * @param DoliDB $db Database handler + * @param ProductCombination $productCombination Product combination + * @param int $fkPriceLevel Price level * * @return ProductCombinationLevel */ From 9293d1917a5241cdc793eec0412076952574e10e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 12:37:30 +0200 Subject: [PATCH 66/86] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index e62d0e3760a..4c25e32c9da 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1210,10 +1210,9 @@ class ProductCombinationLevel /** * Create new Product Combination Price level from Parent * - * @param DoliDB $db Database handler - * @param ProductCombination $productCombination Product combination - * @param int $fkPriceLevel Price level - * + * @param DoliDB $db Database handler + * @param ProductCombination $productCombination Product combination + * @param int $fkPriceLevel Price level * @return ProductCombinationLevel */ public static function createFromParent(DoliDB $db, ProductCombination $productCombination, $fkPriceLevel) From 38ed033b8a96a86ef1238cf0314526796cff2666 Mon Sep 17 00:00:00 2001 From: kev-73 <69631660+kev-73@users.noreply.github.com> Date: Thu, 3 Sep 2020 14:03:40 +0200 Subject: [PATCH 67/86] New: add week number for month view in agenda Agenda, view by month : add a column on left side of agenda, which containt the week number for each line, so for each week. Column width at 2%, no change for width of others columns, because with 14% by defalut, so 14*7=98, the 2% for new column is available. For get date and week number, use fonctions and variables already define in file. --- htdocs/comm/action/index.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index dd29d84cbc3..8742e4d91af 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1210,6 +1210,8 @@ if (empty($action) || $action == 'show_month') // View by month print '
'; print ''; print ' '; + // Column title of weeks numbers + echo ' '; $i = 0; while ($i < 7) { @@ -1232,6 +1234,24 @@ if (empty($action) || $action == 'show_month') // View by month //var_dump($eventarray); for ($iter_week = 0; $iter_week < 6; $iter_week++) { echo " \n"; + // Get date of the current day, format 'yyyy-mm-dd' + if ($tmpday <= 0) // If number of the current day is in previous month + { + $currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday); + } + elseif ($tmpday <= $max_day_in_month) // If number of the current day is in current month + { + $currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday); + } + else // If number of the current day is in next month + { + $currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month); + } + // Get week number for the targeted date '$currdate0' + $numweek0 = date("W", strtotime(date($currdate0))); + // Show the week number, and define column width + echo ' '; + for ($iter_day = 0; $iter_day < 7; $iter_day++) { if ($tmpday <= 0) { /* Show days before the beginning of the current month (previous month) */ From 9a232b616417b67bd22056408b5a08e4ca2a92a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 15:29:00 +0200 Subject: [PATCH 68/86] Fix menu --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index db1da8c79fd..90003e5b53a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1339,7 +1339,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Reports - $newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire); From a4f1ddaad0e67abf32b776a71434fe24a2805c1a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 3 Sep 2020 17:22:27 +0200 Subject: [PATCH 69/86] NEW send context and remove new lines on create ticket --- ...terface_50_modTicket_TicketEmail.class.php | 25 +++++++++++-------- htdocs/ticket/class/ticket.class.php | 24 +++++++++++++++--- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 3b915dee032..5d1f730f9ae 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -198,7 +198,7 @@ class InterfaceTicketEmail extends DolibarrTriggers /* Send email to admin */ $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin'); - $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n"; + $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'

'; $message_admin .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; $message_admin .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; $message_admin .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; @@ -217,14 +217,16 @@ class InterfaceTicketEmail extends DolibarrTriggers $message_admin .= '

    '.$langs->trans('Company').' : '.$object->thirdparty->name.'

    '; } - $message_admin .= '

    '.$langs->trans('Message').' :
    '.$object->message.'

    '; + $message = $object->message; + if (!dol_textishtml($message)) { + $message = dol_nl2br($message); + } + $message_admin .= '

    '.$langs->trans('Message').' :
    '.$message.'

    '; $message_admin .= '

    '.$langs->trans('SeeThisTicketIntomanagementInterface').'

    '; $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; $replyto = $from; - $message_admin = dol_nl2br($message_admin); - $trackid = 'tic'.$object->id; if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { @@ -232,7 +234,7 @@ class InterfaceTicketEmail extends DolibarrTriggers $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); + $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket'); if ($mailfile->error) { dol_syslog($mailfile->error, LOG_DEBUG); } else { @@ -263,7 +265,7 @@ class InterfaceTicketEmail extends DolibarrTriggers $mimetype = array(); $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer'); - $message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n"; + $message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id).'

    '; $message_customer .= '
    • '.$langs->trans('Title').' : '.$object->subject.'
    • '; $message_customer .= '
    • '.$langs->trans('Type').' : '.$object->type_label.'
    • '; $message_customer .= '
    • '.$langs->trans('Category').' : '.$object->category_label.'
    • '; @@ -291,7 +293,12 @@ class InterfaceTicketEmail extends DolibarrTriggers } $message_customer .= '
    '; - $message_customer .= '

    '.$langs->trans('Message').' :
    '.$object->message.'

    '; + + $message = $object->message; + if (!dol_textishtml($message)) { + $message = dol_nl2br($message); + } + $message_customer .= '

    '.$langs->trans('Message').' :
    '.$message.'

    '; $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id; $message_customer .= '

    '.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$url_public_ticket.'

    '; $message_customer .= '

    '.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'

    '; @@ -299,8 +306,6 @@ class InterfaceTicketEmail extends DolibarrTriggers $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; $replyto = $from; - $message_customer = dol_nl2br($message_customer); - $trackid = 'tic'.$object->id; if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { @@ -308,7 +313,7 @@ class InterfaceTicketEmail extends DolibarrTriggers $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid); + $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket'); if ($mailfile->error) { dol_syslog($mailfile->error, LOG_DEBUG); } else { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index c9e7c4cc416..021fb1cfbf5 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2539,7 +2539,11 @@ class Ticket extends CommonObject // Message send $message = $langs->trans('TicketMessageMailIntroText'); $message .= '

    '; - $message .= GETPOST('message', 'none'); + $messagePost = GETPOST('message', 'restricthtml'); + if (!dol_textishtml($messagePost)) { + $messagePost = dol_nl2br($messagePost); + } + $message .= $messagePost; // Customer company infos $message .= '

    '; @@ -2588,7 +2592,11 @@ class Ticket extends CommonObject $message = $langs->trans('TicketMessageMailIntroText'); $message .= '

    '; - $message .= GETPOST('message', 'restricthtml'); + $messagePost = GETPOST('message', 'restricthtml'); + if (!dol_textishtml($messagePost)) { + $messagePost = dol_nl2br($messagePost); + } + $message .= $messagePost; // Coordonnées client $message .= '

    '; @@ -2657,9 +2665,19 @@ class Ticket extends CommonObject $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro', 'restricthtml') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature', 'restricthtml') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; + if (!dol_textishtml($message_intro)) { + $message_intro = dol_nl2br($message_intro); + } + if (!dol_textishtml($message_signature)) { + $message_signature = dol_nl2br($message_signature); + } // We put intro after - $message = GETPOST('message', 'restricthtml'); + $messagePost = GETPOST('message', 'restricthtml'); + if (!dol_textishtml($messagePost)) { + $messagePost = dol_nl2br($messagePost); + } + $message = $messagePost; $message .= '

    '; foreach ($external_contacts as $key => $info_sendto) { From a87797ed66860e5c6a2c126b0d13a88b5350d5ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 18:52:09 +0200 Subject: [PATCH 70/86] Debug recruitment module --- .../class/recruitmentcandidature.class.php | 2 +- .../class/recruitmentjobposition.class.php | 4 ++- htdocs/recruitment/recruitmentindex.php | 27 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 0be25758617..bb2e0e2a18d 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -712,7 +712,7 @@ class RecruitmentCandidature extends CommonObject $label .= '
    '; $label .= ''.$langs->trans('Ref').': '.$this->ref; $label .= '
    '.$langs->trans('Email').': '.$this->email; - $label .= '
    '.$langs->trans('Fullname').': '.$this->getFullName($langs); + $label .= '
    '.$langs->trans('Name').': '.$this->getFullName($langs); if (isset($this->status)) { $label .= '
    '.$langs->trans("Status").": ".$this->getLibStatut(5); } diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index e7fb5ba1e48..3591a8c089a 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -911,7 +911,9 @@ class RecruitmentJobPosition extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_CANCELED) $statusType = 'status6'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_RECRUITED) $statusType = 'status6'; + if ($status == self::STATUS_CANCELED) $statusType = 'status9'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 45240512b11..b63a3a8fc9b 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -116,8 +116,8 @@ if ($conf->use_javascript_ajax) { $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES), (isset($vals[$status]) ? (int) $vals[$status] : 0)); if ($status == RecruitmentJobPosition::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == RecruitmentJobPosition::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == RecruitmentJobPosition::STATUS_RECRUITED) $colorseries[$status] = $badgeStatus4; + if ($status == RecruitmentJobPosition::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus4; + if ($status == RecruitmentJobPosition::STATUS_RECRUITED) $colorseries[$status] = $badgeStatus6; if ($status == RecruitmentJobPosition::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; if (empty($conf->use_javascript_ajax)) @@ -195,7 +195,7 @@ if ($conf->use_javascript_ajax) if ($status == RecruitmentCandidature::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) $colorseries[$status] = $badgeStatus4; if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) $colorseries[$status] = $badgeStatus5; - if ($status == RecruitmentCandidature::STATUS_REFUSED) $colorseries[$status] = $badgeStatus8; + if ($status == RecruitmentCandidature::STATUS_REFUSED) $colorseries[$status] = $badgeStatus9; if ($status == RecruitmentCandidature::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; if (empty($conf->use_javascript_ajax)) @@ -323,7 +323,7 @@ $max = 3; // Last modified job position if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { - $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms"; + $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status"; $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; @@ -343,7 +343,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm print '
'; - print ''; + print ''; print ''; if ($num) { @@ -361,13 +361,16 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm print '"; print '"; + print '"; print ''; $i++; } $db->free($resql); } else { - print ''; + print ''; } print "
#
'.$numweek0.''; print $langs->trans("BoxTitleLatestModifiedJobPositions", $max); print ''.$langs->trans("FullList").''.$langs->trans("FullList").'
'; print "'.dol_print_date($db->jdate($objp->tms), 'day')."'; + print $staticrecruitmentjobposition->getLibStatut(3); + print "
'.$langs->trans("None").'
'.$langs->trans("None").'

"; } else { @@ -378,7 +381,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm // Last modified job position if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { - $sql = "SELECT rc.rowid, rc.ref, rc.date_creation, rc.tms"; + $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -399,7 +402,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm print '
'; print $langs->trans("BoxTitleLatestModifiedCandidatures", $max); print ''.$langs->trans("FullList").''.$langs->trans("FullList").'
'.$staticrecruitmentcandidature->getNomUrl(1, '').''; print "'.dol_print_date($db->jdate($objp->tms), 'day')."'; + print $staticrecruitmentcandidature->getLibStatut(3); + print "
'.$langs->trans("None").'
'.$langs->trans("None").'

"; } else { From aafe3234054ac237a1c5b5ab51da0b7f7cf546ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 19:11:56 +0200 Subject: [PATCH 71/86] css --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 8742e4d91af..1971b2db8dc 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1250,8 +1250,8 @@ if (empty($action) || $action == 'show_month') // View by month // Get week number for the targeted date '$currdate0' $numweek0 = date("W", strtotime(date($currdate0))); // Show the week number, and define column width - echo ' '.$numweek0.''; - + echo ' '.$numweek0.''; + for ($iter_day = 0; $iter_day < 7; $iter_day++) { if ($tmpday <= 0) { /* Show days before the beginning of the current month (previous month) */ From 614c18848638ba8c9cdbc27b764858cb91c6cbfb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 19:29:00 +0200 Subject: [PATCH 72/86] css --- htdocs/theme/eldy/global.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 8898049a237..2b985bde752 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4485,7 +4485,7 @@ table.cal_month td { padding-left: 1px !important; padding-right: 1px !important .cal_other_month_right { border-right: solid 1px #C0C0C0; } .cal_other_month { /* opacity: 0.6; */ background: #EAEAEA; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_past_month { /* opacity: 0.6; */ background: #EEEEEE; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } -.cal_current_month { background: #FFFFFF; border-left: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } +.cal_current_month { background: #FFFFFF; border-left: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px !important; } .cal_current_month_peruserleft { background: #FFFFFF; border-left: solid 2px #6C7C7B; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today { background: #FDFDF0; border-left: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today_peruser { background: #FDFDF0; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } @@ -4502,7 +4502,7 @@ table.cal_month td { padding-left: 1px !important; padding-right: 1px !important .cal_today_peruser_impair { background: #F8F8F0; } .peruser_busy { } .peruser_notbusy { opacity: 0.5; } -div.event { margin: 8px; border-radius: 4px; box-shadow: 2px 2px 5px rgba(100, 100, 100, 0.2); } +div.event { margin-left: 8px; margin-right: 8px; margin-bottom: 8px; margin-top: 4px; border-radius: 4px; box-shadow: 2px 2px 5px rgba(100, 100, 100, 0.2); } table.cal_event { border: none; border-collapse: collapse; margin-bottom: 1px; min-height: 20px; filter: saturate(0.8); border-radius: 3px; } table.cal_event td { border: none; padding-: 2px; padding-: 2px; padding-top: 0px; padding-bottom: 0px; } table.cal_event td.cal_event { padding: 4px 4px !important; } From 1408c862f628718ee9b8a4bf4291f199d2883dd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Sep 2020 21:23:58 +0200 Subject: [PATCH 73/86] css --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 1971b2db8dc..ce3a9f26509 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -467,7 +467,7 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on $s .= "\n".''."\n"; $s .= '