From 26a40e30e3a452a8f11590bea4417754841f3655 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 23 Dec 2020 14:46:07 +0100 Subject: [PATCH 001/928] multicurrency update online and change some behaviors --- htdocs/multicurrency/multicurrency_rate.php | 185 +++++++++----------- 1 file changed, 82 insertions(+), 103 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index eae788b0587..376269c0806 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -46,7 +46,8 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id_rate_selected = GETPOST('id_rate', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_date_sync = GETPOST('search_date_sync', 'alpha'); +$search_date_sync = dol_mktime(0, 0, 0, GETPOST('search_date_syncmonth', 'int'), GETPOST('search_date_syncday', 'int'), GETPOST('search_date_syncyear', 'int')); +$search_date_sync_end = dol_mktime(0, 0, 0, GETPOST('search_date_sync_endmonth', 'int'), GETPOST('search_date_sync_endday', 'int'), GETPOST('search_date_sync_endyear', 'int')); $search_rate = GETPOST('search_rate', 'alpha'); $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -58,12 +59,13 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) $sortfield = "cr.date_sync"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -200,6 +202,7 @@ if (empty($reshook)) { $sall = ""; $search_date_sync = ""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -233,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if ($action != "updateRate") { +if (!in_array( $action, array("updateRate", "deleteRate"))) { print ''; print ''; print ''."\n"; @@ -243,15 +246,15 @@ if ($action != "updateRate") { print ''; print ''; - print '
'.$langs->trans("FormCreateRate").'
'; + print '
'; print ' '; print ' '; print ''; - print ''; + print ''; print ' '; print ' '; @@ -267,54 +270,7 @@ if ($action != "updateRate") { print '
'; } -if ($action == "updateRate") { - $current_rate = new CurrencyRate($db); - $current_rate->fetch(intval($id_rate_selected)); - if ($current_rate) { - $curr = new MultiCurrency($db); - $resultcurrentCurrency = $curr->fetch($current_rate->fk_multicurrency); - - if ($resultcurrentCurrency) { - $currency_code = $curr->code; - } else { - $currency_code = ''; - } - - print '
'.$langs->trans('Date').''; - print $form->selectDate($dateinput, 'dateinput'); + print $form->selectDate($dateinput, 'dateinput', 0, 0, 1); print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').'
'; - print ''; - print ''."\n"; - print '
'.$langs->trans("FormUpdateRate").'
'; - - $form = new Form($db); - print ''; - print ''; - - print ''; - print ' '; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print '
'.$langs->trans('Date').''; - print $form->selectDate($current_rate->date_sync, 'dateinput'); - print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; - print ''; - print ''; - print ''; - print ''.$langs->trans('CancelUpdate').''; - - print '
'; - print ''; - } else { - dol_syslog("currency_rate:list:update", LOG_WARNING); - } -} $sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; @@ -325,7 +281,11 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); +if ($search_date_sync && $search_date_sync_end ){ + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +} elseif ($search_date_sync && !$search_date_sync_end) { + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); +} if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; @@ -374,9 +334,10 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sall) $param .= "&sall=".urlencode($sall); - if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); + if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param .= "&search_code=".urlencode($search_code); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -426,7 +387,7 @@ if ($resql) if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Lines with input filters print ''; @@ -435,14 +396,15 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code if (!empty($arrayfields['m.code']['checked'])) { print ''; } // rate @@ -486,52 +448,69 @@ if ($resql) print ''; - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; + + print ''; + } + else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) + { + print '\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + + // Fields from hook + $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action + print ''; + if (!$i) $totalarray['nbfield']++; } - // code - if (!empty($arrayfields['m.code']['checked'])) - { - print '\n"; - - if (!$i) $totalarray['nbfield']++; - } - - // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) $totalarray['nbfield']++; - print "\n"; $i++; } From a37bb4c6f23c506b176d2c977a8e5a947294b582 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 23 Dec 2020 13:51:13 +0000 Subject: [PATCH 002/928] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -236,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if (!in_array( $action, array("updateRate", "deleteRate"))) { +if (!in_array($action, array("updateRate", "deleteRate"))) { print '
'; - print ''; + print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); + print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); print ''; - print ''; + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print '
'; - print $obj->date_sync; - print "' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; + print $obj->code." ".$obj->name; + print "'; + print $obj->rate; + print "'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; - print $obj->code." ".$obj->name; - print "'; - print $obj->rate; - print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print '
'; print ''; print ''."\n"; From 367a038a1555b464ca5527be645f5947e9d59b20 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 24 Dec 2020 09:55:09 +0100 Subject: [PATCH 003/928] hotfix : idate on create currency --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..a7bf7f2c7f7 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $dateinput; + $currencyRate_static->date_sync = $db->idate($dateinput); $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 20720ae0dd50ad9036f1b1f6103130fe1de77f4f Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 11 Jan 2021 14:06:21 +0100 Subject: [PATCH 004/928] remove idate --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 69d471c62dd..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $db->idate($dateinput); + $currencyRate_static->date_sync = $dateinput; $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 6b451bd870a55c33a40b5b55b5116d35d55018aa Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 1 Feb 2021 09:31:30 +0100 Subject: [PATCH 005/928] use form->selectdate --- htdocs/multicurrency/multicurrency_rate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index b8aaf0064c8..21d64734f8b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,8 +396,8 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code @@ -503,7 +503,7 @@ if ($resql) { $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode='. '1'. '">'.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } From 7966c6ed6d7d9291e2f6c01fbaa03ddb74a83ab8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Feb 2021 08:34:12 +0000 Subject: [PATCH 006/928] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 21d64734f8b..09749ae612e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,7 +396,7 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } From 6c8293612d807d6eae8b9fd8daa45f7d962d96c1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 16:41:48 +0100 Subject: [PATCH 007/928] 13.0 --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 371c8be2f5e..18ae79180a0 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,10 @@ htdocs/includes/squizlabs/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association + +cyberoffice/ +mycyberoffice/ + # Node Modules build/yarn-error.log build/node_modules/ From 7c0d3d4d142b9aedcf7e177a08041622257ee6fb Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 8 Apr 2021 18:03:46 +0200 Subject: [PATCH 008/928] create custom masks in product cards --- htdocs/product/card.php | 23 +++++++++++++++++++++-- htdocs/product/class/product.class.php | 13 ++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 094ce8670a9..26ee8c5c186 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -307,6 +307,8 @@ if (empty($reshook)) { $object->status = GETPOST('statut'); $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); + $object->batch_mask = GETPOST('batch_mask', 'alpha'); + $object->barcode_type = GETPOST('fk_barcode_type'); $object->barcode = GETPOST('barcode'); @@ -475,6 +477,7 @@ if (empty($reshook)) { $object->status = GETPOST('statut', 'int'); $object->status_buy = GETPOST('statut_buy', 'int'); $object->status_batch = GETPOST('status_batch', 'aZ09'); + $object->batch_mask = GETPOST('batch_mask', 'alpha'); $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); // removed from update view so GETPOST always empty /* @@ -1545,10 +1548,26 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Batch number managment if ($conf->productbatch->enabled) { if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print ''; + print ''; + if ($object->status_batch !== '0' + && (($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { + $inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK; + print ''; + $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $inherited_mask; + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes5"); + print ''; + } + print ''; } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 16bbc508ac9..bcfaee9c0dc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -264,6 +264,13 @@ class Product extends CommonObject */ public $status_batch = 0; + /** + * If allowed, we can edit batch or serial number mask for each product + * + * @var string + */ + public $batch_mask = ''; + /** * Customs code * @@ -698,6 +705,7 @@ class Product extends CommonObject $sql .= ", '".$this->db->escape($this->canvas)."'"; $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); + $sql .= ", '".$this->db->escape($this->batch_mask)."'"; $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql .= ")"; @@ -1059,6 +1067,8 @@ class Product extends CommonObject $sql .= ", tosell = ".(int) $this->status; $sql .= ", tobuy = ".(int) $this->status_buy; $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); + $sql .= ", batch_mask = '".$this->db->escape($this->batch_mask)."'"; + $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int) $this->finished); $sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); $sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null'); @@ -2170,7 +2180,7 @@ class Product extends CommonObject } else { $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export, pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; } - $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; + $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { @@ -2210,6 +2220,7 @@ class Product extends CommonObject $this->status = $obj->tosell; $this->status_buy = $obj->tobuy; $this->status_batch = $obj->tobatch; + $this->batch_mask = $obj->batch_mask; $this->customcode = $obj->customcode; $this->country_id = $obj->fk_country; From 000342c2d8fb6677260a2761515419fe9eca69e6 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 9 Apr 2021 13:40:37 +0200 Subject: [PATCH 009/928] custom masks : create, edit and display --- htdocs/langs/en_US/productbatch.lang | 3 ++- htdocs/langs/fr_FR/productbatch.lang | 3 ++- htdocs/product/card.php | 29 ++++++++++++++++++++++++-- htdocs/product/class/product.class.php | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index a63442d4b74..26dc9650308 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -27,4 +27,5 @@ StockDetailPerBatch=Stock detail per lot SerialNumberAlreadyInUse=Serial number %s is already used for product %s TooManyQtyForSerialNumber=You can only have one product %s for serial number %s BatchLotNumberingModules=Options for automatic generation of batch products managed by lots -BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers \ No newline at end of file +BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers +ManageLotMask=Custom mask \ No newline at end of file diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index eed5a063318..81551a38dca 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -27,4 +27,5 @@ StockDetailPerBatch=Stock détaillé par lot SerialNumberAlreadyInUse=Le numéro de série %s est déjà utilisé pour le produit %s TooManyQtyForSerialNumber=Vous ne pouvez avoir qu'un produit %s avec le numéro de série %s BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lot -BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série \ No newline at end of file +BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série +ManageLotMask=Masque personnalisé \ No newline at end of file diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 26ee8c5c186..7754a84926b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1086,10 +1086,28 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Batch number management if (!empty($conf->productbatch->enabled)) { - print ''; + print ''; + // Product specific batch number management + $status_batch = GETPOST('status_batch'); + if ($status_batch !== '0' + && (($status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || ($status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { + $inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK; + print ''; + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes5"); + print ''; + } + print ''; + } $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; @@ -2055,6 +2073,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; + if ((($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { + print ''; + + } } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bcfaee9c0dc..4fc6f378d11 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -678,6 +678,7 @@ class Product extends CommonObject $sql .= ", canvas"; $sql .= ", finished"; $sql .= ", tobatch"; + $sql .= ", batch_mask"; $sql .= ", fk_unit"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; From eef5b9514d3f1ca219ef807e23aa633bd6547225 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 9 Apr 2021 16:55:54 +0200 Subject: [PATCH 010/928] wip --- .../eventorganization/attendee_subscription.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 885058d34bb..2e49ad131d9 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -263,6 +263,19 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->commit(); + + $project = new Project($db); + $resultproject = $project->fetch($object->fk_project); + if ($resultproject < 0){ + $error++; + $errmsg .= $project->error; + } else { + if (!empty($project->price_registration)){ + // @todo traiter invoice et payment page + } + } + + // invoice //Header("Location: ".$urlback); //exit; } else { From ebd5f292318c538e88709fffc2681f7f87e2c0c0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 15:44:25 +0200 Subject: [PATCH 011/928] invoice OK except price, wip on the payment page --- .../attendee_subscription.php | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index b044ad2e914..172e6cee798 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -66,6 +66,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Init vars @@ -78,6 +80,12 @@ $action = GETPOST('action', 'aZ09'); $key = 'DV3PH'; $id = dol_decode(GETPOST('id'), $key); +$conference = new ConferenceOrBooth($db); +$resultconf = $conference->fetch($id); +if ($resultconf < 0) { + setEventMessages(null, $object->errors, "errors"); +} + // Securekey check $securekey = GETPOST('securekey', 'alpha'); if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) { @@ -258,22 +266,39 @@ if (empty($reshook) && $action == 'add') { } } } - if (!$error) { $db->commit(); - $project = new Project($db); - $resultproject = $project->fetch($object->fk_project); - if ($resultproject < 0){ + $resultproject = $project->fetch($conference->fk_project); + if ($resultproject < 0){ $error++; $errmsg .= $project->error; } else { - if (!empty($project->price_registration)){ - // @todo traiter invoice et payment page + var_dump($project->price_registration); + if (!empty(floatval($project->price_registration))){ + $facture = new Facture($db); + //$facture->rowid = ; + //$facture->ref = ; + //$facture->entity = ; + $facture->type = 0; + $facture->socid = $thirdparty->id; + $facture->paye = 0; + //$facture->fk_user_modif = ; + //$facture->fk_cond_reglement = ; + //$facture->tms = ; + //$facture->fk_statut = ; + $facture->date = dol_now(); + $resultfacture = $facture->create($user); + } else { + // No price has been set + // Validating the subscription + $confattendee->setStatut(1); + global $dolibarr_main_url_root; + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; + Header("Location: ".$redirection); + exit; } } - - // invoice //Header("Location: ".$urlback); //exit; } else { @@ -289,12 +314,6 @@ if (empty($reshook) && $action == 'add') { $form = new Form($db); $formcompany = new FormCompany($db); -$conference = new ConferenceOrBooth($db); -$resultconf = $conference->fetch($id); -if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); -} - llxHeaderVierge($langs->trans("NewSubscription")); From 15d103e957f94e63d1b9b50fd80bd7fcff69ad4f Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 15:52:49 +0200 Subject: [PATCH 012/928] subs validation for free conferences added --- htdocs/langs/en_US/eventorganization.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 03fb460d6b9..302790f91f0 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -98,3 +98,7 @@ MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference EvntOrgStartDuration = This conference starts on EvntOrgEndDuration = and ends on +# +# SubscriptionOk page +# +SubscriptionOk = Your subscription to this conference has been validated From e1fb368d3a40662623f02199f528540a073055b7 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 16:50:56 +0200 Subject: [PATCH 013/928] wip --- .../public/eventorganization/attendee_subscription.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 172e6cee798..0adf783ee05 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -274,7 +274,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $project->error; } else { - var_dump($project->price_registration); + global $dolibarr_main_url_root; if (!empty(floatval($project->price_registration))){ $facture = new Facture($db); //$facture->rowid = ; @@ -288,12 +288,15 @@ if (empty($reshook) && $action == 'add') { //$facture->tms = ; //$facture->fk_statut = ; $facture->date = dol_now(); - $resultfacture = $facture->create($user); + $resultfacture = $facture->create($user); + //@todo rediriger page paiement + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + Header("Location: ".$redirection); + exit; } else { // No price has been set // Validating the subscription $confattendee->setStatut(1); - global $dolibarr_main_url_root; $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; Header("Location: ".$redirection); exit; From 0965f28bf74fc02948a4b9332a947cf0d0f2ebd6 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Mon, 12 Apr 2021 17:56:57 +0200 Subject: [PATCH 014/928] a pinch of jquery to display only what we need when we need it --- htdocs/product/card.php | 90 ++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7754a84926b..e6b3adb7439 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -307,8 +307,10 @@ if (empty($reshook)) { $object->status = GETPOST('statut'); $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); - $object->batch_mask = GETPOST('batch_mask', 'alpha'); - + if ($object->status_batch !== 0) { + $object->batch_mask = GETPOST('batch_mask'); + } + else $object->batch_mask = ''; $object->barcode_type = GETPOST('fk_barcode_type'); $object->barcode = GETPOST('barcode'); @@ -477,7 +479,10 @@ if (empty($reshook)) { $object->status = GETPOST('statut', 'int'); $object->status_buy = GETPOST('statut_buy', 'int'); $object->status_batch = GETPOST('status_batch', 'aZ09'); - $object->batch_mask = GETPOST('batch_mask', 'alpha'); + if ($object->status_batch !== 0) { + $object->batch_mask = GETPOST('batch_mask', 'alpha'); + } + else $object->batch_mask = ''; $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); // removed from update view so GETPOST always empty /* @@ -1092,20 +1097,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Product specific batch number management $status_batch = GETPOST('status_batch'); - if ($status_batch !== '0' - && (($status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') - || ($status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { - $inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK; - print ''; + if ($status_batch !== '0') { $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= $langs->trans("GenericMaskCodes2"); $tooltip .= $langs->trans("GenericMaskCodes3"); $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= $langs->trans("GenericMaskCodes5"); - print ''; + print ''; + if (($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') || ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced')) { + $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; + $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; + print ''; + } + print ''; } + print ''; } @@ -1570,20 +1595,47 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); print $form->selectarray('status_batch', $statutarray, $object->status_batch); print ''; - if ($object->status_batch !== '0' - && (($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') - || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { - $inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK; - print ''; - $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $inherited_mask; + if ($object->status_batch !== '0') { $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= $langs->trans("GenericMaskCodes2"); $tooltip .= $langs->trans("GenericMaskCodes3"); $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= $langs->trans("GenericMaskCodes5"); - print ''; + if ($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') { + $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; + } + if ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') { + $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; + } + $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; + $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; + print ''; + + print ''; } print ''; } From bb74a8b1b52f4e4a5f52a0f27a47e4d0876f4a08 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 12 Apr 2021 22:01:46 +0200 Subject: [PATCH 015/928] NEW: Add constant MAIN_BUGTRACK_URL to add possibility to redirect to other service --- htdocs/main.inc.php | 67 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a4c54275041..3b60747bd01 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2743,38 +2743,41 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ if (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; - $bugbaseurl .= '&title='; - $bugbaseurl .= urlencode("Bug: "); - $bugbaseurl .= '&body='; - $bugbaseurl .= urlencode("# Instructions\n"); - $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); - $bugbaseurl .= urlencode("*Please:*\n"); - $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); - $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("# Bug\n"); - $bugbaseurl .= urlencode("[*Short description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Environment\n"); - $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); - $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); - $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); - $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); - $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); - $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Expected and actual behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); - $bugbaseurl .= urlencode("[*Files*]\n"); - $bugbaseurl .= urlencode("\n"); - + if (!empty($conf->global->MAIN_BUGTRACK_URL)) { + $bugbaseurl = $conf->global->MAIN_BUGTRACK_URL; + } else { + $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; + $bugbaseurl .= '&title='; + $bugbaseurl .= urlencode("Bug: "); + $bugbaseurl .= '&body='; + $bugbaseurl .= urlencode("# Instructions\n"); + $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); + $bugbaseurl .= urlencode("*Please:*\n"); + $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); + $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("# Bug\n"); + $bugbaseurl .= urlencode("[*Short description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Environment\n"); + $bugbaseurl .= urlencode("- **Version**: " . DOL_VERSION . "\n"); + $bugbaseurl .= urlencode("- **OS**: " . php_uname('s') . "\n"); + $bugbaseurl .= urlencode("- **Web server**: " . $_SERVER["SERVER_SOFTWARE"] . "\n"); + $bugbaseurl .= urlencode("- **PHP**: " . php_sapi_name() . ' ' . phpversion() . "\n"); + $bugbaseurl .= urlencode("- **Database**: " . $db::LABEL . ' ' . $db->getVersion() . "\n"); + $bugbaseurl .= urlencode("- **URL(s)**: " . $_SERVER["REQUEST_URI"] . "\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Expected and actual behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); + $bugbaseurl .= urlencode("[*Files*]\n"); + $bugbaseurl .= urlencode("\n"); + } // Execute hook printBugtrackInfo $parameters = array('bugbaseurl'=>$bugbaseurl); From 0d136d68068b1f2b4028c895ad50c73b07634aff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:08:56 +0200 Subject: [PATCH 016/928] Enhance barcode scanner tool --- htdocs/langs/en_US/productbatch.lang | 3 +- htdocs/product/inventory/inventory.php | 40 ++++++++++++-------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 26dc9650308..879368e624b 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -28,4 +28,5 @@ SerialNumberAlreadyInUse=Serial number %s is already used for product %s TooManyQtyForSerialNumber=You can only have one product %s for serial number %s BatchLotNumberingModules=Options for automatic generation of batch products managed by lots BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers -ManageLotMask=Custom mask \ No newline at end of file +QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned +ManageLotMask=Custom mask diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 8d3378fb779..8efc5b75bb6 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -265,22 +265,9 @@ if (empty($reshook)) { $form = new Form($db); $formproduct = new FormProduct($db); -llxHeader('', $langs->trans('Inventory'), ''); +$help_url = ''; -// Example : Adding jquery code -print ''; +llxHeader('', $langs->trans('Inventory'), $help_url); // Part to show record @@ -335,7 +322,7 @@ if ($object->id > 0) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; /* @@ -472,26 +459,37 @@ if ($object->id > 0) { } + // Popup for mass barcode scanning if ($action == 'updatebyscaning') { + print '
'; + print ''."\n"; print '
'; print '
Barcode scanner tool...

'; - print 'Scan a product barcode
'; - print '     Qty
'; + print ' Autodetect if we scan a product barcode or a lot/serial barcode
'; + print ' Scan a product barcode
'; + print ' Scan a product lot or serial number
'; - print '
'.$langs->trans("or").'
'; + print $langs->trans("QtyToAddAfterBarcodeScan").'
'; + print ''; + + /*print '
'.$langs->trans("or").'
'; print '
'; - print 'Scan a product lot or serial number
'; print '     Qty
'; - + */ print '
'; + print '
'; + print '
'; + print ''.$langs->trans("FeatureNotYetAvailable").''; // TODO Add javascript so each scan will add qty into the inventory page + an ajax save. + print '
'; print '
'; + print ''; } From f69ccbbab85af033f24f4c297c49b5f116150e71 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 13 Apr 2021 10:31:24 +0200 Subject: [PATCH 017/928] remove empty line --- htdocs/langs/en_US/productbatch.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 879368e624b..b51fed15820 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -29,4 +29,4 @@ TooManyQtyForSerialNumber=You can only have one product %s for serial number %s BatchLotNumberingModules=Options for automatic generation of batch products managed by lots BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned -ManageLotMask=Custom mask +ManageLotMask=Custom mask \ No newline at end of file From a95911e096979641785314229ca0e0c2e09ed91f Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 13 Apr 2021 11:21:41 +0200 Subject: [PATCH 018/928] stickler corrections --- htdocs/product/card.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e6b3adb7439..79857364158 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -309,8 +309,7 @@ if (empty($reshook)) { $object->status_batch = GETPOST('status_batch'); if ($object->status_batch !== 0) { $object->batch_mask = GETPOST('batch_mask'); - } - else $object->batch_mask = ''; + } else $object->batch_mask = ''; $object->barcode_type = GETPOST('fk_barcode_type'); $object->barcode = GETPOST('barcode'); @@ -481,8 +480,7 @@ if (empty($reshook)) { $object->status_batch = GETPOST('status_batch', 'aZ09'); if ($object->status_batch !== 0) { $object->batch_mask = GETPOST('batch_mask', 'alpha'); - } - else $object->batch_mask = ''; + } else $object->batch_mask = ''; $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); // removed from update view so GETPOST always empty /* @@ -1132,7 +1130,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } print ''; - } $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; @@ -1609,11 +1606,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; } $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; - $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; + $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; print '
'; - + print ''; + '; + } else { + print ''; + } } print ''; @@ -1633,6 +1631,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { }) }) '; + } else { + print ''; } print ''; } From bc78b870208932174df02f485ddb567a4ae3d569 Mon Sep 17 00:00:00 2001 From: Givriz Date: Tue, 13 Apr 2021 16:32:19 +0200 Subject: [PATCH 025/928] pvpv8 continuous integration --- htdocs/admin/mails_senderprofile_list.php | 12 +-- htdocs/admin/mails_templates.php | 102 +++++++++++----------- htdocs/core/tpl/list_print_total.tpl.php | 2 +- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 8f781318995..ae190db715c 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -88,7 +88,7 @@ foreach ($object->fields as $key => $val) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) { + if (!empty($val['searchall'])) { $fieldstosearchall['t.'.$key] = $val['label']; } } @@ -102,7 +102,7 @@ foreach ($object->fields as $key => $val) { } } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( @@ -240,7 +240,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($object->ismultientitymanaged == 1) { @@ -497,11 +497,11 @@ foreach ($object->fields as $key => $val) { if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -552,7 +552,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index cdb9c10ec87..73ebcc1d4be 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -45,10 +45,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langsArray=array("errors", "admin", "mails", "languages"); -if ($conf->adherent->enabled) { +if (!empty($conf->adherent->enabled)) { $langsArray[]='members'; } -if ($conf->eventorganization->enabled) { +if (!empty($conf->eventorganization->enabled)) { $langsArray[]='eventorganization'; } @@ -181,55 +181,55 @@ $elementList = array(); $elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --'; $elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --'; $elementList['user'] = img_picto('', 'user', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToUser')); -if ($conf->adherent->enabled && $user->rights->adherent->lire) { +if (!empty($conf->adherent->enabled) && !empty($user->rights->adherent->lire)) { $elementList['member'] = img_picto('', 'object_member', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToMember')); } -if ($conf->recruitment->enabled && $user->rights->recruitment->recruitmentjobposition->read) { +if (!empty($conf->recruitment->enabled) && !empty($user->rights->recruitment->recruitmentjobposition->read)) { $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="paddingright"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures')); } -if ($conf->societe->enabled && $user->rights->societe->lire) { +if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) { $elementList['thirdparty'] = img_picto('', 'company', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToThirdparty')); } -if ($conf->projet->enabled) { +if (!empty($conf->projet->enabled)) { $elementList['project'] = img_picto('', 'project', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToProject')); } -if ($conf->propal->enabled && $user->rights->propal->lire) { +if (!empty($conf->propal->enabled) && !empty($user->rights->propal->lire)) { $elementList['propal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendProposal')); } -if ($conf->commande->enabled && $user->rights->commande->lire) { +if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) { $elementList['order_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendOrder')); } -if ($conf->facture->enabled && $user->rights->facture->lire) { +if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { $elementList['facture_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendInvoice')); } -if ($conf->expedition->enabled) { +if (!empty($conf->expedition->enabled)) { $elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment')); } -if ($conf->reception->enabled) { +if (!empty($conf->reception->enabled)) { $elementList['reception_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception')); } -if ($conf->ficheinter->enabled) { +if (!empty($conf->ficheinter->enabled)) { $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention')); } -if ($conf->supplier_proposal->enabled) { +if (!empty($conf->supplier_proposal->enabled)) { $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation')); } -if (($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_order->enabled && $user->rights->supplier_order->lire)) { +if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire))) { $elementList['order_supplier_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder')); } -if (($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_invoice->enabled && $user->rights->supplier_invoice->lire)) { +if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) { $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice')); } -if ($conf->contrat->enabled && $user->rights->contrat->lire) { +if (!empty($conf->contrat->enabled) && !empty($user->rights->contrat->lire)) { $elementList['contract'] = img_picto('', 'contract', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendContract')); } -if ($conf->ticket->enabled && $user->rights->ticket->read) { +if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) { $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket')); } -if ($conf->agenda->enabled) { +if (!empty($conf->agenda->enabled)) { $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush')); } -if ($conf->eventorganization->enabled && $user->rights->eventorganization->read) { +if (!empty($conf->eventorganization->enabled) && !empty($user->rights->eventorganization->read)) { $elementList['eventorganization_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization')); } @@ -254,7 +254,7 @@ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -1178,98 +1178,98 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { - if ($fieldlist[$field] == 'fk_user') { + if ($value == 'fk_user') { print ''; - } elseif ($fieldlist[$field] == 'lang') { + } elseif ($value == 'lang') { print ''; - } elseif ($fieldlist[$field] == 'type_template') { + } elseif ($value == 'type_template') { // Le type de template print ''; - } elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) { + } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { continue; - } elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) { + } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { continue; - } elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) { + } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { continue; } else { $size = ''; $class = ''; $classtd = ''; - if ($fieldlist[$field] == 'code') { + if ($value == 'code') { $class = 'maxwidth100'; } - if ($fieldlist[$field] == 'label') { + if ($value == 'label') { $class = 'maxwidth200'; } - if ($fieldlist[$field] == 'private') { + if ($value == 'private') { $class = 'maxwidth50'; $classtd = 'center'; } - if ($fieldlist[$field] == 'position') { + if ($value == 'position') { $class = 'maxwidth50'; $classtd = 'center'; } - if ($fieldlist[$field] == 'libelle') { + if ($value == 'libelle') { $class = 'quatrevingtpercent'; } - if ($fieldlist[$field] == 'topic') { + if ($value == 'topic') { $class = 'quatrevingtpercent'; } - if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') { + if ($value == 'sortorder' || $value == 'sens' || $value == 'category_type') { $size = 'size="2" '; } print ''; - if ($fieldlist[$field] == 'private') { + if ($value == 'private') { if (empty($user->admin)) { - print $form->selectyesno($fieldlist[$field], '1', 1); + print $form->selectyesno($value, '1', 1); } else { //print ''; - print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); + print $form->selectyesno($value, (isset($obj->{$value}) ? $obj->{$value}:''), 1); } } else { - print ''; + print ''; } print ''; } diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index d7252f891ae..62052b82cec 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -1,6 +1,6 @@ $valtotalizable) { $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable; $totalarray['val'][$keytotalizable] = $valtotalizable['total']; From 2e297b575350483a00457af2ed36d5c532ec49aa Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 13 Apr 2021 17:02:58 +0200 Subject: [PATCH 026/928] one more print --- htdocs/product/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 93bb3c65d0e..64e5b844cb0 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1123,10 +1123,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { }) '; } else { - print ''; + print ''; } + } else { + print ''; } - print ''; } From 6814488d86cf2435aaa335a5143f697771289f7d Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 00:51:19 +0200 Subject: [PATCH 027/928] Update list.php --- htdocs/commande/list.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index db6bba130b1..d345bd033be 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -274,7 +274,15 @@ if (empty($reshook)) { $objectclass = 'Commande'; $objectlabel = 'Orders'; $permissiontoread = $user->rights->commande->lire; + $permissiontoadd = $user->rights->commande->creer; $permissiontodelete = $user->rights->commande->supprimer; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ + $permissiontovalidate = $user->rights->commande->order_advance->validate; + $permissiontoclose = $user->rights->commande->order_advance->close; + }else{ + $permissiontovalidate = $user->rights->commande->creer; + $permissiontoclose = $user->rights->commande->creer; + } $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -700,16 +708,21 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( - 'generate_doc'=>$langs->trans("ReGeneratePDF"), - 'builddoc'=>$langs->trans("PDFMerge"), - 'cancelorders'=>$langs->trans("Cancel"), - 'presend'=>$langs->trans("SendByMail"), + 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), + 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), + 'cancelorders'=>img_picto('', 'close_title').' '.$langs->trans("Cancel"), + 'presend'=>img_picto('', 'email').' '.$langs->trans("SendByMail"), ); if ($user->rights->facture->creer) { - $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); + $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } - if ($user->rights->commande->supprimer) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A + if ($permissiontoclose) { + $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); + } + } + if ($permissiontodelete) { + $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); } if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { $arrayofmassactions = array(); @@ -720,7 +733,7 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $user->rights->commande->creer); + $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); // Lines of title fields print ''; @@ -1740,8 +1753,8 @@ if ($resql) { $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->commande->lire; - $delallowed = $user->rights->commande->creer; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } else { From 25ac8bed68b3b512d68c54e5686b223ec0dde8e7 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 01:54:30 +0200 Subject: [PATCH 028/928] Update list.php --- htdocs/commande/list.php | 86 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d345bd033be..4c1a06a9a5d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -11,6 +11,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2021 Anthony Berton * * 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 @@ -279,15 +280,83 @@ if (empty($reshook)) { if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ $permissiontovalidate = $user->rights->commande->order_advance->validate; $permissiontoclose = $user->rights->commande->order_advance->close; + $permissiontocancel = $user->rights->commande->order_advance->annuler; + $permissiontosendbymail = $user->rights->commande->order_advance->send; }else{ $permissiontovalidate = $user->rights->commande->creer; $permissiontoclose = $user->rights->commande->creer; + $permissiontocancel = $user->rights->commande->creer; + $permissiontosendbymail = $user->rights->commande->creer; } $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +if ($action == 'validate' && $permissiontoadd) { + if (GETPOST('confirm') == 'yes') { + $objecttmp = new $objectclass($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->statut == 0) { + if ($objecttmp->valid($user)) { + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + }else{ + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} +// Closed records +if (!$error && $massaction === 'setbilled' && $permissiontoclose) { + $db->begin(); + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->classifyBilled($user, 0); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} /* * View @@ -710,9 +779,18 @@ if ($resql) { $arrayofmassactions = array( 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), - 'cancelorders'=>img_picto('', 'close_title').' '.$langs->trans("Cancel"), - 'presend'=>img_picto('', 'email').' '.$langs->trans("SendByMail"), ); + if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A + if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); + } + } + if ($permissiontosendbymail) { + $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); + } + if ($permissiontocancel) { + $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); + } if ($user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } @@ -757,6 +835,10 @@ if ($resql) { $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction == 'prevalidate') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + } + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; From 92ca59d20b2d51bfc2e0f6510dbb03799f28008c Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 02:23:23 +0200 Subject: [PATCH 029/928] Update list.php --- htdocs/commande/list.php | 55 +++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4c1a06a9a5d..78adb797b88 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -300,7 +300,42 @@ if ($action == 'validate' && $permissiontoadd) { foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 0) { - if ($objecttmp->valid($user)) { + if (!empty($objecttmp->fk_warehouse)){ + $idwarehouse = $objecttmp->fk_warehouse; + }else{ + $idwarehouse = 0; + } + if ($objecttmp->valid($user, $idwarehouse)) { + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + }else{ + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} +if ($action == 'shipped' && $permissiontoadd) { + if (GETPOST('confirm') == 'yes') { + $objecttmp = new $objectclass($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->statut == 1) { + if ($objecttmp->cloture($user)) { setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); @@ -780,24 +815,23 @@ if ($resql) { 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), ); - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontovalidate) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); - } + if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); } if ($permissiontosendbymail) { $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); } + if ($permissiontoclose) { + $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert').' '.$langs->trans("ClassifyShipped"); + } if ($permissiontocancel) { $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); } if ($user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontoclose) { - $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); - } + if ($permissiontoclose) { + $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); } if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); @@ -838,6 +872,9 @@ if ($resql) { if ($massaction == 'prevalidate') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } + if ($massaction == 'preshipped') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1); + } if ($massaction == 'createbills') { //var_dump($_REQUEST); From 632487921506e589004ebb769b25bad36a7a6db2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 00:25:05 +0000 Subject: [PATCH 030/928] Fixing style errors. --- htdocs/commande/list.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 78adb797b88..954c0e95a6d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -277,12 +277,12 @@ if (empty($reshook)) { $permissiontoread = $user->rights->commande->lire; $permissiontoadd = $user->rights->commande->creer; $permissiontodelete = $user->rights->commande->supprimer; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $permissiontovalidate = $user->rights->commande->order_advance->validate; $permissiontoclose = $user->rights->commande->order_advance->close; $permissiontocancel = $user->rights->commande->order_advance->annuler; $permissiontosendbymail = $user->rights->commande->order_advance->send; - }else{ + } else { $permissiontovalidate = $user->rights->commande->creer; $permissiontoclose = $user->rights->commande->creer; $permissiontocancel = $user->rights->commande->creer; @@ -300,9 +300,9 @@ if ($action == 'validate' && $permissiontoadd) { foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 0) { - if (!empty($objecttmp->fk_warehouse)){ + if (!empty($objecttmp->fk_warehouse)) { $idwarehouse = $objecttmp->fk_warehouse; - }else{ + } else { $idwarehouse = 0; } if ($objecttmp->valid($user, $idwarehouse)) { @@ -315,7 +315,7 @@ if ($action == 'validate' && $permissiontoadd) { setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); $error++; } - }else{ + } else { dol_print_error($db); $error++; } @@ -345,7 +345,7 @@ if ($action == 'shipped' && $permissiontoadd) { setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); $error++; } - }else{ + } else { dol_print_error($db); $error++; } From 2f31720896b94ac235e9a4ad7082959a0cdf6c79 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 14 Apr 2021 04:45:17 +0200 Subject: [PATCH 031/928] Maxi debug of societe/product per entity --- htdocs/accountancy/admin/productaccount.php | 12 +-- htdocs/accountancy/customer/card.php | 4 +- htdocs/accountancy/customer/index.php | 12 +-- htdocs/accountancy/customer/lines.php | 6 +- htdocs/accountancy/customer/list.php | 16 ++-- .../accountancy/journal/purchasesjournal.php | 10 ++- htdocs/accountancy/journal/sellsjournal.php | 4 +- htdocs/accountancy/supplier/card.php | 12 ++- htdocs/accountancy/supplier/index.php | 29 ++++++-- htdocs/accountancy/supplier/lines.php | 17 ++++- htdocs/accountancy/supplier/list.php | 14 ++-- htdocs/compta/journal/sellsjournal.php | 4 +- htdocs/core/modules/modFacture.class.php | 4 +- htdocs/core/modules/modProduct.class.php | 6 +- htdocs/core/modules/modService.class.php | 4 +- htdocs/product/class/product.class.php | 8 +- htdocs/product/list.php | 8 +- htdocs/societe/class/societe.class.php | 73 ++++++++++++++++--- 18 files changed, 170 insertions(+), 73 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 2013b0c7295..dd60c33a2e6 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -270,8 +270,8 @@ if (empty($pcgvercode)) { $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; - $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } else { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; @@ -280,14 +280,14 @@ $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ppe." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { - $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, $search_current_account); + $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account); } if ($search_current_account_valid == 'withoutvalidaccount') { $sql .= " AND aa.account_number IS NULL"; @@ -466,7 +466,7 @@ if ($result) { } else { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index f0bcd9f7a49..b3ce892b235 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -102,7 +102,7 @@ if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell,"; + $sql .= " ppe.accountancy_code_sell as code_sell,"; } else { $sql .= " p.accountancy_code_sell as code_sell,"; } @@ -110,7 +110,7 @@ if (!empty($id)) { $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0b32e2802c4..755d03bbb3a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -126,15 +126,15 @@ if ($action == 'validatehistory') { $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; } $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra,"; - if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { - $sql .= " sa.accountancy_code_sell as company_code_sell"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_sell as company_code_sell"; } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } @@ -145,10 +145,10 @@ if ($action == 'validatehistory') { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } - $alias_societe_perentity = empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "s" : "sa"; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 6f522750398..b8cc34c3cae 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -184,9 +184,9 @@ $sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, f $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; } else { - $sql .= " p.accountancy_code_sell,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } $sql .= " aa.rowid as fk_compte, aa.account_number, aa.label as label_account, aa.labelshort as labelshort_account,"; $sql .= " fd.situation_percent,"; @@ -198,7 +198,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index de160fe2b93..4052ed51fdd 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -219,8 +219,8 @@ $sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; - $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; @@ -229,8 +229,8 @@ $sql .= " p.tosell as status, p.tobuy as status_buy,"; $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " sa.accountancy_code_sell as company_code_sell"; +if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_sell as company_code_sell"; } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } @@ -240,16 +240,16 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } -$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index bf950182798..018cba4ca89 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -106,9 +106,17 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy,"; +} else { + $sql .= " p.accountancy_code_buy,"; +} +$sql .= " aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 1904631775d..a9b6f17a9bd 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -110,14 +110,14 @@ $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tot $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell"; + $sql .= " ppe.accountancy_code_sell"; } else { $sql .= " p.accountancy_code_sell"; } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index cd17df33776..1e7887c1bdc 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -101,10 +101,18 @@ $formaccounting = new FormAccounting($db); if (!empty($id)) { $sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; - $sql .= ", aa.account_number, aa.label"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy as code_buy,"; + } else { + $sql .= " p.accountancy_code_buy as code_buy,"; + } + $sql .= " aa.account_number, aa.label"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 392551708de..ff09479ad03 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -132,20 +132,35 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; - $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export, p.tva_tx as tva_tx_prod,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; + } else { + $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; + } $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; - $sql .= " s.tva_intra, s.accountancy_code_buy as company_code_buy"; + $sql .= " s.tva_intra,"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_buy as company_code_buy"; + } else { + $sql .= " s.accountancy_code_buy as company_code_buy"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + } + $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_product_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 1f81a5d7e2c..deed1299fd5 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -94,6 +94,9 @@ if (empty($user->rights->accounting->mouvements->lire)) { } +$formaccounting = new FormAccounting($db); + + /* * Actions */ @@ -116,7 +119,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_tvaintra = ''; } -if (is_array($changeaccount) && count($changeaccount) > 0) { +if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) { $error = 0; if (!(GETPOST('account_parent', 'int') >= 0)) { @@ -124,7 +127,6 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); } - if (!$error) { $db->begin(); @@ -184,7 +186,11 @@ $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invo $sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,"; $sql .= " aa.label, aa.labelshort, aa.account_number,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tobuy, p.tosell,"; -$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; +} else { + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +} $sql .= " co.code as country_code, co.label as country,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; $parameters = array(); @@ -192,6 +198,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); +} $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 1dcd17ea074..f70ae669204 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -224,8 +224,8 @@ $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_lab $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; - $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; @@ -235,7 +235,7 @@ $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_ $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " sa.accountancy_code_buy as company_code_buy"; + $sql .= " spe.accountancy_code_buy as company_code_buy"; } else { $sql .= " s.accountancy_code_buy as company_code_buy"; } @@ -245,16 +245,16 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } -$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 9fa4168ea0a..367ffffbdea 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -113,7 +113,7 @@ $sql .= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, f $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql .= " p.rowid as pid, p.ref as pref,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell,"; + $sql .= " ppe.accountancy_code_sell,"; } else { $sql .= " p.accountancy_code_sell,"; } @@ -121,7 +121,7 @@ $sql .= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index d1ad993af68..9cc05e5d6f2 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -296,7 +296,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index fd1c7cceca0..344af868b69 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; @@ -296,7 +296,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; @@ -447,7 +447,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 3b21cf046c8..40bb2667741 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; @@ -259,7 +259,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 16bbc508ac9..224f03fdda1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -725,6 +725,8 @@ class Product extends CommonObject // update accountancy for this entity if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; $sql .= " fk_product"; $sql .= ", entity"; @@ -2168,13 +2170,13 @@ class Product extends CommonObject if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } else { - $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export, pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export, ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; } $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if ($id) { $sql .= " WHERE p.rowid = ".((int) $id); @@ -2256,7 +2258,7 @@ class Product extends CommonObject $this->barcode_type = $obj->fk_barcode_type; $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; $this->accountancy_code_buy_export = $obj->accountancy_code_buy_export; $this->accountancy_code_sell = $obj->accountancy_code_sell; $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index dc035187f30..e649179bb5e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -191,7 +191,7 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) { $isInEEC = isInEEC($mysoc); -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; // Definition of fields for lists $arrayfields = array( @@ -364,7 +364,7 @@ $sql .= ' p.tobatch,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,'; @@ -387,7 +387,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; @@ -523,7 +523,7 @@ $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9d449922dd2..29e125de321 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -879,8 +879,10 @@ class Societe extends CommonObject $sql .= ", import_key"; $sql .= ", fk_multicurrency"; $sql .= ", multicurrency_code"; - $sql .= ", accountancy_code_buy"; - $sql .= ", accountancy_code_sell"; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + } $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); @@ -893,8 +895,10 @@ class Societe extends CommonObject $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + } $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -904,6 +908,28 @@ class Societe extends CommonObject $ret = $this->update($this->id, $user, 0, 1, 1, 'add'); + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . $this->id . " AND entity = " . $conf->entity); + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; + $sql .= " fk_soc"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToUpdateAccountancyForEntity'; + } + } + // Ajout du commercial affecte if ($this->commercial_id != '' && $this->commercial_id != -1) { $this->add_commercial($user, $this->commercial_id); @@ -1414,10 +1440,10 @@ class Societe extends CommonObject $sql .= ",order_min_amount= ".($this->order_min_amount != '' ? $this->order_min_amount : 'null'); $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null'); $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; - - $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; - $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; - + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'"; + } $sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null"); $sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null"); @@ -1499,6 +1525,28 @@ class Societe extends CommonObject $action = 'update'; + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . $this->id . " AND entity = " . $conf->entity); + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; + $sql .= " fk_soc"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToUpdateAccountancyForEntity'; + } + } + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -1589,7 +1637,11 @@ class Societe extends CommonObject $sql .= ', s.fk_effectif as effectif_id'; $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; - $sql .= ', s.accountancy_code_buy, s.accountancy_code_sell'; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ', s.accountancy_code_buy, s.accountancy_code_sell'; + } else { + $sql .= ', spe.accountancy_code_buy, spe.accountancy_code_sell'; + } $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; $sql .= ', s.fk_account, s.tva_assuj'; @@ -1609,6 +1661,9 @@ class Societe extends CommonObject $sql .= ', i.libelle as label_incoterms'; $sql .= ', sr.remise_client, model_pdf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); + } $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; From 69fd2cf24ca3bb6a52de1924686d0af25636d14e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 02:50:23 +0000 Subject: [PATCH 032/928] Fixing style errors. --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e649179bb5e..735c0f6481f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -523,7 +523,7 @@ $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { From c83819bd90796d0f185e9ff11ef7c7071666527d Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 14 Apr 2021 09:44:01 +0200 Subject: [PATCH 033/928] NEW : Add possibility to exports userGroups fields on user exports --- htdocs/core/modules/modUser.class.php | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index e84998635ff..6298e5d01e9 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -231,7 +231,8 @@ class modUser extends DolibarrModules 'u.birth'=>'DateOfBirth', 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification", 'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion', - 'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId" + 'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId", + 'g.nom'=>"Group" ); $this->export_TypeFields_array[$r] = array( 'u.rowid'=>'Numeric', 'u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.employee'=>'Boolean', 'u.job'=>'Text', @@ -239,22 +240,24 @@ class modUser extends DolibarrModules 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', - 'u.fk_user'=>"List:user:login", - 'u.birth'=>'Date', - 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname" + 'u.fk_user'=>"List:user:login", + 'u.birth'=>'Date', + 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname", + 'g.nom'=>"Text" ); $this->export_entities_array[$r] = array( 'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.employee'=>'user', 'u.job'=>'user', 'u.gender'=>'user', - 'u.accountancy_code'=>'user', - 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", - 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', - 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', - 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', - 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', - 'u.birth'=>'user', - 'u.datec'=>"user", 'u.tms'=>"user", - 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', - 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member" + 'u.accountancy_code'=>'user', + 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", + 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', + 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', + 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', + 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', + 'u.birth'=>'user', + 'u.datec'=>"user", 'u.tms'=>"user", + 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', + 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member", + 'g.nom'=>"Group" ); $keyforselect = 'user'; $keyforelement = 'user'; @@ -267,6 +270,8 @@ class modUser extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON u.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'usergroup_user as ug ON u.rowid = ug.fk_user'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'usergroup as g ON ug.fk_usergroup = g.rowid'; $this->export_sql_end[$r] .= ' WHERE u.entity IN ('.getEntity('user').')'; // Imports From bcab8d5164e055be9a8e2af70a146626389559d1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 07:49:18 +0000 Subject: [PATCH 034/928] Fixing style errors. --- htdocs/core/modules/modUser.class.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 6298e5d01e9..01303892435 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -240,23 +240,23 @@ class modUser extends DolibarrModules 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', - 'u.fk_user'=>"List:user:login", - 'u.birth'=>'Date', - 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname", + 'u.fk_user'=>"List:user:login", + 'u.birth'=>'Date', + 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname", 'g.nom'=>"Text" ); $this->export_entities_array[$r] = array( 'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.employee'=>'user', 'u.job'=>'user', 'u.gender'=>'user', - 'u.accountancy_code'=>'user', - 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", - 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', - 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', - 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', - 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', - 'u.birth'=>'user', - 'u.datec'=>"user", 'u.tms'=>"user", - 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', - 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member", + 'u.accountancy_code'=>'user', + 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", + 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', + 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user', + 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', + 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', + 'u.birth'=>'user', + 'u.datec'=>"user", 'u.tms'=>"user", + 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', + 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member", 'g.nom'=>"Group" ); $keyforselect = 'user'; From 55afc59db25c55839a8df10dcdd267d9a763ed60 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 14:33:11 +0200 Subject: [PATCH 035/928] removed useless fetch, moved link to the fetch method of the conferenceorbooth class, wip on service to use on the invoice --- htdocs/admin/eventorganization.php | 19 +++++++++++++++++++ .../class/conferenceorbooth.class.php | 12 ++++++++++++ .../conferenceorbooth_card.php | 12 +----------- htdocs/langs/en_US/eventorganization.lang | 2 ++ .../attendee_subscription.php | 4 ++-- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index b6a964d8617..c76d9a5c188 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -61,6 +61,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -276,6 +278,23 @@ if ($action == 'edit') { });'; print ''; } + } elseif ($var['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + print ''; + print ''; + print "\n"; + } + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + print ''; + print ''; + } + print "\n"; } else { print ''; } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 41fe4ebd94d..b859c10a98d 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -237,7 +237,19 @@ class ConferenceOrBooth extends ActionComm */ public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '') { + global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id, $conf, $langs; + $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); + + $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; + + $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); + $link_subscription .= '&securekey='.urlencode($encodedsecurekey); + + $this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); + $this->pubregister = $link_subscription; + $this->getActionCommFields(); return $result; } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 15b52eda038..fc232406ce9 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -493,18 +493,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner - global $dolibarr_main_url_root; - - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; - - $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); - $link_subscription .= '&securekey='.urlencode($encodedsecurekey); - - $object->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); - $object->pubregister = $link_subscription; $keyforbreak='pubregister'; - + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; //var_dump($object); // Other attributes. Fields from hook formObjectOptions and Extrafields. diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index fbee3de4e3d..3fc655b92e9 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -82,6 +82,8 @@ EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations Attendees = Attendees EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference +SERVICE_BOOTH_LOCATION = Service used for the invoice row about a booth location +SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION = Service used for the invoice row about an attendee subscription to a conference # # Status # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index a47a93557d3..9aa1ca7d2e0 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -299,14 +299,14 @@ if (empty($reshook) && $action == 'add') { $facture->paye = 0; //@todo price and taxes to add $tva = get_default_tva($mysoc, $thirdparty); - $facture->date = dol_now(); + $resultfacture = $facture->create($user); if ($resultfacture < 0){ $error++; $errmsg .= $facture->error; } else { - $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + // @todo corriger la réf qui est surement celle de la facture au lieu du client $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?amount='.$project->price_registration.'&source=conferenceattendeesubscription&ref='.$thirdparty->ref; Header("Location: ".$redirection); exit; From a91a9256a34f8a7d59d5d9cae36ff531d4471941 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 13:49:26 +0100 Subject: [PATCH 036/928] Fix extrafields in list --- htdocs/partnership/partnership_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 408b7355ab1..e03ed536806 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -266,7 +266,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks From 4e45011e45bc44f41434d19396fca77b7c413fb6 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 13:59:38 +0100 Subject: [PATCH 037/928] Manage Partnership for third-party --- htdocs/core/modules/modPartnership.class.php | 4 +- htdocs/langs/en_US/partnership.lang | 1 + htdocs/partnership/admin/setup.php | 4 +- .../partnership/class/partnership.class.php | 154 ++++- .../class/partnershiputils.class.php | 2 +- htdocs/partnership/partnership_card.php | 22 +- htdocs/societe/partnership.php | 614 ++++++++++++++++++ 7 files changed, 743 insertions(+), 58 deletions(-) create mode 100644 htdocs/societe/partnership.php diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 442e01b56f6..9f8c1437eee 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -180,10 +180,10 @@ class modPartnership extends DolibarrModules $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { - $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); $fk_mainmenu = "members"; } else { - $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); $fk_mainmenu = "companies"; } diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 63b3bec0bb6..e9fb30d1fd6 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -37,6 +37,7 @@ PartnershipAboutPage = Partnership about page # # Object # +PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party DatePartnershipStart=Start date DatePartnershipEnd=End date diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index d55daab2347..6ba689cbd00 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -91,10 +91,10 @@ if ($action == 'setting') { $partnership->tabs = array(); if ($modulemenu == 'member') { - $partnership->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $partnership->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); $fk_mainmenu = "members"; } else { - $partnership->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $partnership->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); $fk_mainmenu = "companies"; } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 019d72a6012..6a676bf24e9 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -100,26 +100,7 @@ class Partnership extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), - 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, '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, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Accepté', '2'=>'Refusé', '9'=>'Annulé'),), - 'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'date_partnership_start' => array('type'=>'datetime', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), - 'date_partnership_end' => array('type'=>'datetime', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), - ); + public $fields=array(); public $rowid; public $ref; public $fk_soc; @@ -188,12 +169,37 @@ class Partnership extends CommonObject $this->db = $db; + $fk_soc_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 0 : 1; + $fk_member_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 1 : 0; + + $this->fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>$fk_soc_visible, 'index'=>1,), + 'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>$fk_member_visible, 'index'=>1,), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, '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'=>0, 'visible'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Accepté', '2'=>'Refusé', '9'=>'Annulé'),), + 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), + 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), + ); + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { $this->fields['rowid']['visible'] = 0; } - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { - $this->fields['entity']['enabled'] = 0; - } + // if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + // $this->fields['entity']['enabled'] = 0; + // } // Example to show how to set values of fields definition dynamically /*if ($user->rights->partnership->read) { @@ -229,6 +235,7 @@ class Partnership extends CommonObject */ public function create(User $user, $notrigger = false) { + $this->status = 0; return $this->createCommon($user, $notrigger); } @@ -333,20 +340,97 @@ class Partnership extends CommonObject /** * Load object in memory from the database + * Get object from database. Get also lines. * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id of object to load + * @param string $ref Ref of object + * @param int $fk_soc_or_member fk_soc or fk_member + * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $ref = null) + public function fetch($id, $ref = null, $fk_soc_or_member = null) { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); + global $conf; + + // Check parameters + if (empty($id) && empty($ref) && empty($fk_soc_or_member)) { + return -1; + } + + $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status'; + $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; + $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; + $sql .= ', p.note_private, p.note_public'; + $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.reason_decline_or_cancel'; + $sql .= ', p.import_key, p.model_pdf'; + + $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; + + if ($id) { + $sql .= " WHERE p.rowid=".$id; + } else { + $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid + } + + if ($ref) { + $sql .= " AND p.ref='".$this->db->escape($ref)."'"; + } + + if($fk_soc_or_member){ + $sql .= ' AND'; + if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') + $sql .= ' p.fk_member = '; + else + $sql .= ' p.fk_soc = '; + $sql .= $fk_soc_or_member; + $sql .= ' ORDER BY p.date_partnership_end DESC'; + } + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + if ($obj) { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->rowid = $obj->rowid; + $this->ref = $obj->ref; + $this->fk_soc = $obj->fk_soc; + $this->fk_member = $obj->fk_member; + $this->status = $obj->status; + $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start); + $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end); + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->fk_user_creat = $obj->fk_user_creat; + $this->tms = $obj->tms; + $this->fk_user_modif = $obj->fk_user_modif; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->last_main_doc = $obj->last_main_doc; + $this->count_last_url_check_error = $obj->count_last_url_check_error; + $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel; + $this->import_key = $obj->import_key; + $this->model_pdf = $obj->model_pdf; + + $this->lines = array(); + + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + $this->db->free($result); + + return 1; + } else { + $this->error = 'Partnership with id '.$id.' not found sql='.$sql; + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; } - return $result; } + /** * Load object lines in memory from the database * @@ -768,9 +852,9 @@ class Partnership extends CommonObject public function refused($user, $notrigger = '') { // Protection - // if ($this->status != self::STATUS_DRAFT) { - // return 0; - // } + if ($this->status == self::STATUS_REFUSED) { + return 0; + } /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate)))) @@ -816,7 +900,7 @@ class Partnership extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) { + if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) { return 0; } diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 61659e6075c..08c61b3454c 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -35,7 +35,7 @@ dol_include_once('partnership/lib/partnership.lib.php'); class PartnershipUtils { public $db; //!< To store db handler - public $error; //!< To return error code (or message) + public $error; //!< To return error code (or message) public $errors=array(); //!< To return several error codes (or messages) diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index dbf889137d8..c44174af52c 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -108,9 +108,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); + foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha')) { $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -581,7 +579,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Back to draft - if ($object->status == $object::STATUS_ACCEPTED) { + if ($object->status != $object::STATUS_DRAFT) { print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); } @@ -598,23 +596,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - // Clone - // print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - - - // if ($permissiontoadd) { - // if ($object->status == $object::STATUS_ENABLED) { - // print ''.$langs->trans("Disable").''."\n"; - // } else { - // print ''.$langs->trans("Enable").''."\n"; - // } - // } - // Cancel if ($permissiontoadd) { if ($object->status == $object::STATUS_ACCEPTED) { print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes&token='.newToken(), '', $permissiontoadd); - } elseif ($object->status == $object::STATUS_CANCELED) { + } elseif ($object->status > $object::STATUS_ACCEPTED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); } @@ -622,7 +608,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Refuse if ($permissiontoadd) { - if ($object->status != $object::STATUS_CANCELED) { + if ($object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { print ''.$langs->trans("Refuse").''."\n"; } } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php new file mode 100644 index 00000000000..2484936f686 --- /dev/null +++ b/htdocs/societe/partnership.php @@ -0,0 +1,614 @@ + + * Copyright (C) 2021 NextGestion + * + * 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 partnership_card.php + * \ingroup partnership + * \brief Page to create/edit/view partnership + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/partnership/class/partnership.class.php'); +dol_include_once('/partnership/lib/partnership.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("companies","partnership@partnership", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Security check +$socid = GETPOST('socid', 'int'); +if (!empty($user->socid)) { + $socid = $user->socid; +} + +$societe = new Societe($db); +if ($socid > 0) { + $societe->fetch($socid); +} + +// Initialize technical objects +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); + +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; + + +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); + +$partnershipid = $object->fetch(0, "", $socid); +if(empty($action) && empty($partnershipid)){ + $action = 'create'; +} +if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) accessforbidden(); + +if(empty($socid) && $object){ + $socid = $object->fk_soc; +} +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); + +if (empty($reshook)) { + $error = 0; + + $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?socid='.($socid > 0 ? $socid : '__ID__'); + + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record + + if ($action == 'add' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $old_start_date = $object->date_partnership_start; + + $object->fk_soc = $socid; + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->date_creation = $now; + $object->fk_user_creat = $user->id; + $object->entity = $conf->entity; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->create($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'update' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $object->oldcopy = clone $object; + + $old_start_date = $object->date_partnership_start; + + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->fk_user_creat = $user->id; + $object->fk_user_modif = $user->id; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'confirm_close' || $action == 'update_extras') { + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); + exit; + } + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // // Actions to send emails + // $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; + // $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO'; + // $trackid = 'partnership'.$object->id; + // include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); + +$title = $langs->trans("Partnership"); +llxHeader('', $title); + +$form = new Form($db); + +if ($socid) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $langs->load("companies"); + + $societe = new Societe($db); + $result = $societe->fetch($socid); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + $head = societe_prepare_head($societe); + + print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'company'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($societe, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print '
'.$langs->trans("FormCreateRate").''; - print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); - print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; - print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print '
'.$langs->trans("ManageLotSerial").''; + print '
'.$langs->trans("ManageLotSerial").''; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); print $form->selectarray('status_batch', $statutarray, $object->status_batch); - print '
'.$langs->trans("ManageLotMask").''; + print $form->textwithpicto('', $tooltip, 1, 1); + print '
'.$langs->trans("ManageLotSerial").''; + print '
'.$langs->trans("ManageLotSerial").''; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch')); - print '
'.$langs->trans("ManageLotMask").''; + print $form->textwithpicto('', $tooltip, 1, 1); + print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print '
'.$langs->trans("ManageLotMask").''; + print $object->batch_mask; + print '
'.$langs->trans("ManageLotMask").''; - print $form->textwithpicto('', $tooltip, 1, 1); - print ''.$langs->trans("ManageLotMask").''; + print $form->textwithpicto('', $tooltip, 1, 1); + print '
'.$langs->trans("ManageLotMask").''; - print $form->textwithpicto('', $tooltip, 1, 1); + print ''.$langs->trans("ManageLotMask").''; + print $form->textwithpicto('', $tooltip, 1, 1); print '
'; print $form->textwithpicto('', $tooltip, 1, 1); print '
'; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], empty($search[$key]) ? '' : $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print '
'; if ($user->admin) { - print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth200'); + print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth200'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me $forcedvalue = $user->id; } else { - if ($obj && !empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0) { + if ($obj && !empty($obj->{$value}) && $obj->{$value} > 0) { $fuser = new User($db); - $fuser->fetch($obj->{$fieldlist[$field]}); + $fuser->fetch($obj->{$value}); print $fuser->getNomUrl(1); $forcedvalue = $fuser->id; } else { - $forcedvalue = $obj->{$fieldlist[$field]}; + $forcedvalue = $obj->{$value}; } } - $keyname = $fieldlist[$field]; + $keyname = $value; print ''; } print ''; if (!empty($conf->global->MAIN_MULTILANGS)) { $selectedlang = GETPOSTISSET('langcode') ?GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') { - $selectedlang = $obj->{$fieldlist[$field]}; + $selectedlang = $obj->{$value}; } print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } else { - if (!empty($obj->{$fieldlist[$field]})) { - print $obj->{$fieldlist[$field]}.' - '.$langs->trans('Language_'.$obj->{$fieldlist[$field]}); + if (!empty($obj->{$value})) { + print $obj->{$value}.' - '.$langs->trans('Language_'.$obj->{$value}); } - $keyname = $fieldlist[$field]; + $keyname = $value; if ($keyname == 'lang') { $keyname = 'langcode'; // Avoid conflict with lang param } - print ''; + print ''; } print ''; - if ($context == 'edit' && !empty($obj->{$fieldlist[$field]}) && !in_array($obj->{$fieldlist[$field]}, array_keys($elementList))) { + if ($context == 'edit' && !empty($obj->{$value}) && !in_array($obj->{$value}, array_keys($elementList))) { // Current template type is an unknown type, so we must keep it as it is. - print ''; - print $obj->{$fieldlist[$field]}; + print ''; + print $obj->{$value}; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1, '', 0, 1); } print '
'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + print '
'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + print '
'; + + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field + print ''; + } + + if ($societe->client) { + print ''; + } + + if ($societe->fournisseur) { + print ''; + } + + print '
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_client)); + $tmpcheck = $societe->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; + print $langs->trans('SupplierCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_fournisseur)); + $tmpcheck = $societe->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + $params = ''; + + $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); + + print '
'; + +} else { + dol_print_error('', 'Parameter socid not defined'); +} + +$object->fields['fk_soc']['visible'] = 0; + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + // print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print ''; +} + +// Part to edit record +if (($partnershipid || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("Partnership"), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + + + print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $res = $object->fetch_optionals(); + + // $head = partnershipPrepareHead($object); + // print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto); + + $linkback = ''; + dol_banner_tab($object, 'id', $linkback, 0, 'rowid', 'ref'); + + $formconfirm = ''; + + // Close confirmation + if ($action == 'close') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmCloseAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + } + // Reopon confirmation + if ($action == 'reopen') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToReopon'), $langs->trans('ConfirmReoponAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); + } + + // Refuse confirmatio + if ($action == 'refuse') { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + ); + + // 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('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + + if ($action != 'presend') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + + if ($object->status == $object::STATUS_DRAFT) { + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$socid.'&action=edit', '', $permissiontoadd); + } + + // Cancel + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ACCEPTED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // if ($action != 'presend') { + // print '
'; + // print ''; // ancre + + // $includedocgeneration = 0; + + // // Documents + // if ($includedocgeneration) { + // $objref = dol_sanitizeFileName($object->ref); + // $relativepath = $objref.'/'.$objref.'.pdf'; + // $filedir = $conf->partnership->dir_output.'/'.$object->element.'/'.$objref; + // $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + // $genallowed = $user->rights->partnership->read; // If you can read, you can build the PDF to read content + // $delallowed = $user->rights->partnership->write; // If you can create/edit, you can remove a file on card + // print $formfile->showdocuments('partnership:Partnership', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + // } + + // // Show links to link elements + // $linktoelem = $form->showLinkToObjectBlock($object, null, array('partnership')); + // $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + // print '
'; + + // $MAXEVENT = 10; + + // $morehtmlright = ''; + // $morehtmlright .= $langs->trans("SeeAll"); + // $morehtmlright .= ''; + + // // List of actions on element + // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + // $formactions = new FormActions($db); + // $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); + + // print '
'; + // } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'partnership'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->partnership->dir_output; + $trackid = 'partnership'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); From 6238ff0321db496a52195fbc2e052f6647876d8b Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 15:52:46 +0200 Subject: [PATCH 038/928] wip on asking for the company name only if price is set --- .../eventorganization/attendee_subscription.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 3d1ee6272cc..a18912da4ef 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -81,6 +81,9 @@ $email = GETPOST("email"); $encodedid = GETPOST('id'); $id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$project = new Project($db); + + // Getting 'securekey'.'id' from Post and decoding it $encodedsecurekeyandid = GETPOST('securekey', 'alpha'); $securekeyandid = dol_decode($encodedsecurekeyandid, $dolibarr_main_instance_unique_id); @@ -193,10 +196,11 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."
\n"; } - /*if (!GETPOST("societe")) { + // If the price has been set, name is required for the invoice + if (!GETPOST("societe") && !empty(floatval($project->price_registration))) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Societe"))."
\n"; - }*/ + } if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { $error++; $langs->load("errors"); @@ -350,7 +354,11 @@ print ''." // Email print ''."\n"; // Company -print ''."\n"; +print ''."\n"; // Address print ''."\n"; From 2f3f2509b29b3c85f5d91d7f390bcff4b3994787 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 15:54:21 +0200 Subject: [PATCH 039/928] wip on asking for the company name only if price is set v2 --- .../eventorganization/attendee_subscription.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index a18912da4ef..e40ad552b5c 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -81,8 +81,18 @@ $email = GETPOST("email"); $encodedid = GETPOST('id'); $id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); -$project = new Project($db); +$conference = new ConferenceOrBooth($db); +$resultconf = $conference->fetch($id); +if ($resultconf < 0) { + setEventMessages(null, $object->errors, "errors"); +} +$project = new Project($db); +$resultproject = $project->fetch($conference->fk_project); +if ($resultproject < 0){ + $error++; + $errmsg .= $project->error; +} // Getting 'securekey'.'id' from Post and decoding it $encodedsecurekeyandid = GETPOST('securekey', 'alpha'); From 3d5e439d9253fd5e28115922a3af039e19165dcd Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 15:55:59 +0200 Subject: [PATCH 040/928] company name is now required if price is set --- htdocs/public/eventorganization/attendee_subscription.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index e40ad552b5c..3084de3f416 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -66,6 +66,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Init vars From a596424328dd79f0312a675ee82820a5187c3c41 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Apr 2021 16:01:48 +0200 Subject: [PATCH 041/928] FIX : Rebuild sequence for postgres only after query "INSERT INTO llx_salary(rowid --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 3f17d23b51f..27f3f08ae15 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -423,4 +423,7 @@ ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL afte ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; -ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any \ No newline at end of file +ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any + +-- Rebuild sequence for postgres only after query "INSERT INTO llx_salary(rowid, ..." +-- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); From 6f0f527a890458f2c50664e71b5b5885c3fda4c5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 14:04:33 +0000 Subject: [PATCH 042/928] Fixing style errors. --- .../eventorganization/attendee_subscription.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 3084de3f416..d3f9e6f06bd 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -85,14 +85,14 @@ $id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); $conference = new ConferenceOrBooth($db); $resultconf = $conference->fetch($id); if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); + setEventMessages(null, $object->errors, "errors"); } $project = new Project($db); $resultproject = $project->fetch($conference->fk_project); -if ($resultproject < 0){ - $error++; - $errmsg .= $project->error; +if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; } // Getting 'securekey'.'id' from Post and decoding it @@ -366,8 +366,8 @@ print '
'.$langs->trans("Email").' *
'.$langs->trans("Company").'
'.$langs->trans("Company"); +if(!empty(floatval($project->price_registration))){ + print '*'; +} +print '
'.$langs->trans("Address").''."\n"; print '
'." print ''."\n"; // Company print ''."\n"; // Address From 9b668959458171d1de5493c0a8be81edc9eb050f Mon Sep 17 00:00:00 2001 From: Givriz Date: Wed, 14 Apr 2021 16:06:53 +0200 Subject: [PATCH 043/928] Update mails_templates.php --- htdocs/admin/mails_templates.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 73ebcc1d4be..86f1cc00063 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -55,6 +55,7 @@ if (!empty($conf->eventorganization->enabled)) { $langs->loadLangs($langsArray); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; +$massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $id = GETPOST('id', 'int'); @@ -254,7 +255,7 @@ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } From 4d643db4e6772dec06ad6c46d8f93c0864ff0e20 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Apr 2021 16:14:03 +0200 Subject: [PATCH 044/928] FIX : travis --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 27f3f08ae15..c2489042f5f 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -425,5 +425,5 @@ ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL af ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any --- Rebuild sequence for postgres only after query "INSERT INTO llx_salary(rowid, ..." +-- Rebuild sequence for postgres only after query INSERT INTO llx_salary(rowid, ... -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); From 4700fd467f43ab20aa76f7bd2c7aad5d8f4c3e9b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 14:14:39 +0000 Subject: [PATCH 045/928] Fixing style errors. --- htdocs/partnership/class/partnership.class.php | 9 ++++----- htdocs/societe/partnership.php | 10 +++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 6a676bf24e9..395a3893b7d 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -374,13 +374,12 @@ class Partnership extends CommonObject if ($ref) { $sql .= " AND p.ref='".$this->db->escape($ref)."'"; } - - if($fk_soc_or_member){ + + if ($fk_soc_or_member) { $sql .= ' AND'; - if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') + if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') $sql .= ' p.fk_member = '; - else - $sql .= ' p.fk_soc = '; + else $sql .= ' p.fk_soc = '; $sql .= $fk_soc_or_member; $sql .= ' ORDER BY p.date_partnership_end DESC'; } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 2484936f686..2576c2348c5 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -144,12 +144,12 @@ if (empty($permissiontoread)) accessforbidden(); if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); $partnershipid = $object->fetch(0, "", $socid); -if(empty($action) && empty($partnershipid)){ +if (empty($action) && empty($partnershipid)) { $action = 'create'; } if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) accessforbidden(); -if(empty($socid) && $object){ +if (empty($socid) && $object) { $socid = $object->fk_soc; } /* @@ -262,7 +262,7 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); exit; } - + // Actions when linking object each other include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; @@ -352,7 +352,6 @@ if ($socid) { $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); print '
'; - } else { dol_print_error('', 'Parameter socid not defined'); } @@ -442,8 +441,6 @@ if (($partnershipid || $ref) && $action == 'edit') { // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - - print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), '', ''); $res = $object->fetch_optionals(); @@ -536,7 +533,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (empty($reshook)) { - if ($object->status == $object::STATUS_DRAFT) { print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$socid.'&action=edit', '', $permissiontoadd); } From caf74fe1cb3452c93146ac8a00a89786afaededd Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 16:20:05 +0200 Subject: [PATCH 046/928] pull problem corrected --- .../attendee_subscription.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index faff3d40712..cdb848ed28c 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -293,6 +293,33 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->commit(); + global $dolibarr_main_url_root; + if (!empty(floatval($project->price_registration))){ + $facture = new Facture($db); + $facture->type = 0; + $facture->socid = $thirdparty->id; + $facture->paye = 0; + //@todo price and taxes to add + $tva = get_default_tva($mysoc, $thirdparty); + $facture->date = dol_now(); + $resultfacture = $facture->create($user); + if ($resultfacture < 0){ + $error++; + $errmsg .= $facture->error; + } else { + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + Header("Location: ".$redirection); + exit; + } + + } else { + // No price has been set + // Validating the subscription + $confattendee->setStatut(1); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; + Header("Location: ".$redirection); + exit; + } //Header("Location: ".$urlback); //exit; } else { From 03a944edf5fdab56c91362f10ec859af9f6acf7f Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 16:32:23 +0100 Subject: [PATCH 047/928] Manage membership expiration --- htdocs/partnership/partnership_list.php | 89 +++++++++++++++++++++++-- htdocs/societe/partnership.php | 4 +- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index e03ed536806..e1820d7c8c9 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -77,6 +77,7 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; // load partnership libraries require_once __DIR__.'/class/partnership.class.php'; @@ -112,8 +113,9 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object = new Partnership($db); -$extrafields = new ExtraFields($db); +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$adherent = new Adherent($db); $diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array @@ -123,9 +125,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); +$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + +if($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { @@ -148,6 +150,11 @@ foreach ($object->fields as $key => $val) { $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } +$search_filter = GETPOST("search_filter", 'alpha'); +$filter = GETPOST("filter", 'alpha'); +if ($filter) { + $search_filter = $filter; // For backward compatibility +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); @@ -229,6 +236,7 @@ if (empty($reshook)) { } $toselect = ''; $search_array_options = array(); + $search_filter = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { @@ -263,6 +271,9 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); +if ($managedfor == 'member'){ + $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription'; +} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -278,6 +289,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } +if ($managedfor == 'member'){ + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; +} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -287,6 +302,10 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } +if ($managedfor == 'member') + $sql .= " AND fk_member > 0"; +else + $sql .= " AND fk_soc > 0"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -316,6 +335,17 @@ foreach ($search as $key => $val) { } } } +if ($managedfor == 'member'){ + if ($search_filter == 'withoutsubscription') { + $sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)"; + } + if ($search_filter == 'uptodate') { + $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = 0)"; + } + if ($search_filter == 'outofdate') { + $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = 1)"; + } +} if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -422,6 +452,9 @@ foreach ($search as $key => $val) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($search_filter && $search_filter != '-1') { + $param .= "&search_filter=".urlencode($search_filter); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks @@ -500,6 +533,12 @@ print '
'; // You can use div-table-responsive- print '
'.$langs->trans("Email").' *
'.$langs->trans("Company"); -if(!empty(floatval($project->price_registration))){ - print '*'; +if (!empty(floatval($project->price_registration))) { + print '*'; } print '
'."\n"; +if ($managedfor == 'member'){ + $arrayfields['t.fk_member']['checked'] = 1; +} +else { + $arrayfields['t.fk_soc']['checked'] = 1; +} // Fields title search // -------------------------------------------------------------------- print ''; @@ -533,6 +572,13 @@ foreach ($object->fields as $key => $val) { print ''; } } +// End of subscription date +if ($managedfor == 'member'){ + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -566,6 +612,12 @@ foreach ($object->fields as $key => $val) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } +// End of subscription date +if ($managedfor == 'member'){ + $key = 'datefin'; + $cssforfield = 'center'; + print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -641,6 +693,33 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } } + // End of subscription date + if ($managedfor == 'member'){ + print ''; + } else { + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 2576c2348c5..90071846531 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -139,6 +139,7 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') accessforbidden(); if (empty($conf->partnership->enabled)) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); @@ -283,7 +284,6 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -$formproject = new FormProjets($db); $title = $langs->trans("Partnership"); llxHeader('', $title); @@ -349,8 +349,6 @@ if ($socid) { $params = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); - print '
'; } else { dol_print_error('', 'Parameter socid not defined'); From 5d404836f751afedda3906137b7a571af74f6448 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 16:35:19 +0000 Subject: [PATCH 048/928] Fixing style errors. --- htdocs/partnership/partnership_list.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index e1820d7c8c9..8cd0cf79fd7 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -127,7 +127,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; -if($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; +if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { @@ -271,7 +271,7 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription'; } // Add fields from extrafields @@ -289,7 +289,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; } @@ -304,8 +304,7 @@ if ($object->ismultientitymanaged == 1) { } if ($managedfor == 'member') $sql .= " AND fk_member > 0"; -else - $sql .= " AND fk_soc > 0"; +else $sql .= " AND fk_soc > 0"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -335,7 +334,7 @@ foreach ($search as $key => $val) { } } } -if ($managedfor == 'member'){ +if ($managedfor == 'member') { if ($search_filter == 'withoutsubscription') { $sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)"; } @@ -533,10 +532,9 @@ print '
'; // You can use div-table-responsive- print '
'; + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + print $form->selectarray('search_filter', $selectarray, $search_filter); + print ''; + $result = $adherent->fetch($object->fk_member); + if($result){ + $datefin = $adherent->datefin; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($adherent->hasDelay()) { + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); + } + print ''; + if ($adherent->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($adherent->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } + } + } + print '
'."\n"; -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $arrayfields['t.fk_member']['checked'] = 1; -} -else { +} else { $arrayfields['t.fk_soc']['checked'] = 1; } // Fields title search @@ -573,7 +571,7 @@ foreach ($object->fields as $key => $val) { } } // End of subscription date -if ($managedfor == 'member'){ +if ($managedfor == 'member') { print ''; // Show bugtrack link print ''; print ''; print ''; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 3f17d23b51f..df64b9915bf 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -423,4 +423,6 @@ ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL afte ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; -ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any \ No newline at end of file +ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any + +UPDATE llx_const SET value = 'github' WHERE __DECRYPT('name')__ = 'MAIN_BUGTRACK_ENABLELINK' AND __DECRYPT('value')__ = 1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d52bfb0a6ee..6862a8b0384 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1159,7 +1159,7 @@ DoNotSuggestPaymentMode=Do not suggest NoActiveBankAccountDefined=No active bank account defined OwnerOfBankAccount=Owner of bank account %s BankModuleNotActive=Bank accounts module not enabled -ShowBugTrackLink=Show link "%s" +ShowBugTrackLink=Define link "%s (empty to not display the link / 'github' for the link to the Dolibarr project) Alerts=Alerts DelaysOfToleranceBeforeWarning=Delay before displaying a warning alert for: DelaysOfToleranceDesc=Set the delay before an alert icon %s is shown onscreen for the late element. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3032fc33170..0e13a072a39 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2743,9 +2743,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ if (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if (!empty($conf->global->MAIN_BUGTRACK_URL)) { - $bugbaseurl = $conf->global->MAIN_BUGTRACK_URL; - } else { + if ($conf->global->MAIN_BUGTRACK_ENABLELINK == 'github') { $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; $bugbaseurl .= '&title='; $bugbaseurl .= urlencode("Bug: "); @@ -2777,10 +2775,17 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); $bugbaseurl .= urlencode("[*Files*]\n"); $bugbaseurl .= urlencode("\n"); + + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Report\n"); + } elseif (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) { + $bugbaseurl = $conf->global->MAIN_BUGTRACK_ENABLELINK; + } else { + $bugbaseurl = ""; } // Execute hook printBugtrackInfo - $parameters = array('bugbaseurl'=>$bugbaseurl); + $parameters = array('bugbaseurl' => $bugbaseurl); $reshook = $hookmanager->executeHooks('printBugtrackInfo', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { $bugbaseurl .= $hookmanager->resPrint; @@ -2788,8 +2793,6 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ $bugbaseurl = $hookmanager->resPrint; } - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Report\n"); print '
'; print ''.$langs->trans("FindBug").''; print '
'; From 957968eea2df7a92d01996d07c4e3a54b8fbfc45 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 14 Apr 2021 23:17:26 +0200 Subject: [PATCH 052/928] typo --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6862a8b0384..252067ee538 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1159,7 +1159,7 @@ DoNotSuggestPaymentMode=Do not suggest NoActiveBankAccountDefined=No active bank account defined OwnerOfBankAccount=Owner of bank account %s BankModuleNotActive=Bank accounts module not enabled -ShowBugTrackLink=Define link "%s (empty to not display the link / 'github' for the link to the Dolibarr project) +ShowBugTrackLink=Define link "%s" (empty to not display the link / 'github' for the link to the Dolibarr project) Alerts=Alerts DelaysOfToleranceBeforeWarning=Delay before displaying a warning alert for: DelaysOfToleranceDesc=Set the delay before an alert icon %s is shown onscreen for the late element. From b2a1b0673682e4f752992840fc477aadd1d02b8c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 14 Apr 2021 23:19:10 +0200 Subject: [PATCH 053/928] text --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 252067ee538..553a011514c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1159,7 +1159,7 @@ DoNotSuggestPaymentMode=Do not suggest NoActiveBankAccountDefined=No active bank account defined OwnerOfBankAccount=Owner of bank account %s BankModuleNotActive=Bank accounts module not enabled -ShowBugTrackLink=Define link "%s" (empty to not display the link / 'github' for the link to the Dolibarr project) +ShowBugTrackLink=Define link "%s" (empty to not display the link, 'github' for the link to the Dolibarr project of define an url) Alerts=Alerts DelaysOfToleranceBeforeWarning=Delay before displaying a warning alert for: DelaysOfToleranceDesc=Set the delay before an alert icon %s is shown onscreen for the late element. From 1be8bfe5c01fd9bda4948ac0f1c74d5e884c3e2e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 15 Apr 2021 06:08:41 +0200 Subject: [PATCH 054/928] Text --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 553a011514c..d1596ded0d3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1159,7 +1159,7 @@ DoNotSuggestPaymentMode=Do not suggest NoActiveBankAccountDefined=No active bank account defined OwnerOfBankAccount=Owner of bank account %s BankModuleNotActive=Bank accounts module not enabled -ShowBugTrackLink=Define link "%s" (empty to not display the link, 'github' for the link to the Dolibarr project of define an url) +ShowBugTrackLink=Define the link "%s" (empty to not display this link, 'github' for the link to the Dolibarr project or define directly an url 'https://...') Alerts=Alerts DelaysOfToleranceBeforeWarning=Delay before displaying a warning alert for: DelaysOfToleranceDesc=Set the delay before an alert icon %s is shown onscreen for the late element. From dd7c09582fdc7b19bdaac710e765f9e1f4cf39e2 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 15 Apr 2021 10:45:44 +0200 Subject: [PATCH 055/928] payment page structure ok, still need to confirm the attendee after the payment --- htdocs/admin/eventorganization.php | 57 ++++---- htdocs/langs/en_US/eventorganization.lang | 4 + .../attendee_subscription.php | 64 ++++----- htdocs/public/payment/newpayment.php | 133 ++++++++++++++++++ 4 files changed, 193 insertions(+), 65 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index c76d9a5c188..58f09786e23 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -61,8 +61,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), - 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), - 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -209,12 +209,12 @@ if ($action == 'edit') { print ''; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; print ''; + // Website + print ''; + print ''; + // Address print ''."\n"; } else { $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; + print ''; } // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); @@ -628,8 +624,6 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } @@ -650,7 +644,7 @@ print ''."\n"; // Other attributes -$tpl_context = 'public'; // define templae context to public +$tpl_context = 'public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; @@ -675,11 +669,11 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); } else { jQuery("#budget").val(\'\'); } }); - /*jQuery("#type").change(function() { - if (jQuery("#type").val()==1) { jQuery("#morphy").val(\'mor\'); } - if (jQuery("#type").val()==2) { jQuery("#morphy").val(\'phy\'); } - if (jQuery("#type").val()==3) { jQuery("#morphy").val(\'mor\'); } - if (jQuery("#type").val()==4) { jQuery("#morphy").val(\'mor\'); } + /*jQuery("#typeid").change(function() { + if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); } + if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); } + if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); } + if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); } initturnover(); });*/ function initturnover() { @@ -702,14 +696,18 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { print ''."\n"; } if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount = 0; + + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); } // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''; -} -print "
'; $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); @@ -613,7 +611,7 @@ foreach ($object->fields as $key => $val) { } } // End of subscription date -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $key = 'datefin'; $cssforfield = 'center'; print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; @@ -694,10 +692,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } // End of subscription date - if ($managedfor == 'member'){ + if ($managedfor == 'member') { print ''; $result = $adherent->fetch($object->fk_member); - if($result){ + if ($result) { $datefin = $adherent->datefin; if ($datefin) { print dol_print_date($datefin, 'day'); From 9ca67b81f8b5856e7ae13a97deb96dc98e716ded Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Apr 2021 18:49:21 +0200 Subject: [PATCH 049/928] FIX : correction migration queries for postgres --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index c2489042f5f..ead63c44675 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -273,15 +273,15 @@ create table llx_salary fk_user_modif integer -- user making last change ) ENGINE=innodb; -ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user fk_user integer NULL; +-- VMYSQL4.1 ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user fk_user integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_payment_salary ALTER COLUMN fk_user DROP NOT NULL; ALTER TABLE llx_payment_salary ADD COLUMN fk_salary integer; INSERT INTO llx_salary (rowid, ref, fk_user, amount, fk_projet, fk_typepayment, label, datesp, dateep, entity, note, fk_bank, paye) SELECT ps.rowid, ps.rowid, ps.fk_user, ps.amount, ps.fk_projet, ps.fk_typepayment, ps.label, ps.datesp, ps.dateep, ps.entity, ps.note, ps.fk_bank, 1 FROM llx_payment_salary ps WHERE ps.fk_salary IS NULL; UPDATE llx_payment_salary SET fk_salary = rowid WHERE fk_salary IS NULL; UPDATE llx_payment_salary SET ref = rowid WHERE ref IS NULL; -ALTER TABLE llx_salary CHANGE paye paye smallint default 0 NOT NULL; - +ALTER TABLE llx_salary ALTER COLUMN paye set default 0; DELETE FROM llx_boxes WHERE box_id IN (SELECT rowid FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php'); From 377c73036381d27b3197a0c5615724fe37d59397 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Wed, 14 Apr 2021 21:27:53 +0200 Subject: [PATCH 050/928] add missing group by hook in fichinter list --- htdocs/fichinter/list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d054f5e5bcc..b142613f051 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -259,6 +259,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add GroupBy from hooks +$parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records From 140f098c79263e505f28f084799ce7a2e5c721c2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 14 Apr 2021 23:16:30 +0200 Subject: [PATCH 051/928] NEW: Add constant MAIN_BUGTRACK_URL to add possibility to redirect to other service --- htdocs/admin/ihm.php | 6 +++--- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 4 +++- htdocs/langs/en_US/admin.lang | 2 +- htdocs/main.inc.php | 15 +++++++++------ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 8b799c9c7de..8c504426195 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -211,11 +211,12 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", GETPOST("MAIN_DEFAULT_WORKING_DAYS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST("MAIN_BUGTRACK_ENABLELINK", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'restricthtml')), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'restricthtml')), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST('MAIN_BUGTRACK_ENABLELINK', 'aZ09'), 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; @@ -401,8 +402,7 @@ print '
'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; -print ajax_constantonoff("MAIN_BUGTRACK_ENABLELINK", array(), $conf->entity, 0, 0, 1, 0); -//print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK', $conf->global->MAIN_BUGTRACK_ENABLELINK, 1); +print ''; print ' 
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; + if ($val['enabled']==1) { + $setupnotempty++; + print '
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; if ($val['type'] == 'textarea') { print ''; @@ -1278,6 +1289,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''.img_picto('', 'object_email').' email).'">
'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''.img_picto('', 'globe').'
'.$langs->trans("Address").''; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0299b32663c..bd9613d0645 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -141,6 +141,11 @@ class Adherent extends CommonObject */ public $email; + /** + * @var string url + */ + public $url; + /** * @var array array of socialnetworks */ @@ -309,6 +314,7 @@ class Adherent extends CommonObject 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), + 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>110), 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), @@ -645,6 +651,7 @@ class Adherent extends CommonObject $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); + $this->url = $this->url ?clean_url($this->url, 0) : ''; // Check parameters if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { @@ -670,6 +677,7 @@ class Adherent extends CommonObject $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null"); $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); @@ -1282,7 +1290,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,"; $sql .= " d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql .= " d.note_public,"; - $sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql .= " d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql .= " d.datec as datec,"; $sql .= " d.tms as datem,"; @@ -1361,6 +1369,7 @@ class Adherent extends CommonObject $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; + $this->url = $obj->url; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 97ee2b751ae..c1e75bbe353 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -424,7 +424,7 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,positi INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -ALTER TABLE llx_adherent ADD COLUMN website varchar(255) NULL AFTER email; +ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email; ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; From 17f84c4edc1e4b98b524190c4e5265bb8a1fbd04 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:18:42 +0200 Subject: [PATCH 090/928] Fix new member form use getpost instead FORCEXXX ## Fix use FORCETYPE, FORCECOUNTRYCODE, FORCEMORPHY even if GETPOST bas value ## Fix code style : typeid is note type ## Fix reset amount when $amount is set by script or by hook ## Fix some code style --- htdocs/public/members/new.php | 82 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index e6b7a3e7a38..19fa23af080 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -201,12 +201,12 @@ if (empty($reshook) && $action == 'add') { $langs->load("errors"); $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; } - if (!GETPOST("email")) { + if (!GETPOST('email')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; } } - if (GETPOST('type') <= 0) { + if (GETPOST('typeid') <= 0) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; } @@ -214,21 +214,21 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; } - if (!GETPOST("lastname")) { + if (!GETPOST('lastname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST("firstname")) { + if (!GETPOST('firstname') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } - if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { + if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { $error++; $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; } - $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST("birthmin", 'int'), GETPOST("birthsec", 'int'), GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); - if (GETPOSTISSET("birthmonth") && empty($birthday)) { + $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); + if GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; @@ -240,36 +240,32 @@ if (empty($reshook) && $action == 'add') { } } - if (GETPOSTISSET('public')) { - $public = 1; - } else { - $public = 0; - } + $public = GETPOSTISSET('public') ? 1 : 0; if (!$error) { // email a peu pres correct et le login n'existe pas $adh = new Adherent($db); $adh->statut = -1; $adh->public = $public; - $adh->firstname = GETPOST("firstname"); - $adh->lastname = GETPOST("lastname"); - $adh->gender = GETPOST("gender"); - $adh->civility_id = GETPOST("civility_id"); - $adh->societe = GETPOST("societe"); - $adh->address = GETPOST("address"); - $adh->zip = GETPOST("zipcode"); - $adh->town = GETPOST("town"); - $adh->email = GETPOST("email"); + $adh->firstname = GETPOST('firstname'); + $adh->lastname = GETPOST('lastname'); + $adh->gender = GETPOST('gender'); + $adh->civility_id = GETPOST('civility_id'); + $adh->societe = GETPOST('societe'); + $adh->address = GETPOST('address'); + $adh->zip = GETPOST('zipcode'); + $adh->town = GETPOST('town'); + $adh->email = GETPOST('email'); if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $adh->login = GETPOST("login"); - $adh->pass = GETPOST("pass1"); + $adh->login = GETPOST('login'); + $adh->pass = GETPOST('pass1'); } - $adh->photo = GETPOST("photo"); - $adh->country_id = GETPOST("country_id", 'int'); - $adh->state_id = GETPOST("state_id", 'int'); - $adh->typeid = GETPOST("type", 'int'); - $adh->note_private = GETPOST("note_private"); - $adh->morphy = GETPOST("morphy"); + $adh->photo = GETPOST('photo'); + $adh->country_id = $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE ? $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE : GETPOST('country_id', 'int'); + $adh->state_id = GETPOST('state_id', 'int'); + $adh->typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); + $adh->note_private = GETPOST('note_private'); + $adh->morphy = $conf->global->MEMBER_NEWFORM_FORCEMORPHY ? $conf->global->MEMBER_NEWFORM_FORCEMORPHY : GETPOST('morphy'); $adh->birth = $birthday; @@ -562,11 +558,11 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { $isempty = 0; } print '
'.$langs->trans("Type").' *'; - print $form->selectarray("type", $adht->liste_array(), GETPOST('type') ?GETPOST('type') : $defaulttype, $isempty); + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); print '
'.$langs->trans('State').''; if ($country_code) { print $formcompany->select_state(GETPOST("state_id"), $country_code); - } else { - print ''; } print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Subscription").''; From fcbea36605cc16f51715a9bb8036f2b4164d48d0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 12:21:40 +0000 Subject: [PATCH 091/928] Fixing style errors. --- htdocs/public/members/new.php | 305 +++++++++++++++++----------------- 1 file changed, 152 insertions(+), 153 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 19fa23af080..0920e5976b1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -221,12 +221,12 @@ if (empty($reshook) && $action == 'add') { if (!GETPOST('firstname') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; - } - if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; - } +} +if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; +} $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); if GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; @@ -545,121 +545,121 @@ jQuery(document).ready(function () { '; -print ''."\n"; + print '
'."\n"; -// Type -if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; + // Type + if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; + } + print ''."\n"; + } else { + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } - print ''."\n"; -} else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; -} -// Moral/Physic attribute -$morphys["phy"] = $langs->trans("Physical"); -$morphys["mor"] = $langs->trans("Moral"); -if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; -} else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; -} -// Civility -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// Gender -print ''; -print ''; -// Company -print ''."\n"; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''."\n"; + } else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; + } + // Civility + print ''."\n"; + // Lastname + print ''."\n"; + // Firstname + print ''."\n"; + // Gender + print ''; + print ''; + // Company + print ''."\n"; + // Address + print ''."\n"; + // Zip / Town + print ''; + // Country + print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; -} -// EMail -print ''."\n"; -// Login -if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; -} -// Birthday -print ''."\n"; -// Photo -print ''."\n"; -// Public -print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\n"; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; + } + // EMail + print ''."\n"; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + // Birthday + print ''."\n"; + // Photo + print ''."\n"; + // Public + print ''."\n"; + // Other attributes + $tpl_context = 'public'; // define template context to public + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Comments + print ''; + print ''; + print ''; + print ''."\n"; -// Add specific fields used by Dolibarr foundation for example -if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; -} -if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - - // Set amount for the subscription - $amount = isset($amount) ? $amount : 0; - - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + print ''."\n"; } + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); + } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans('UserTitle').''; -print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Gender").''; -$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); -print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); -print '
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); -print ' / '; -print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); -print '
'.$langs->trans('Country').''; -$country_id = GETPOST('country_id'); -if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); -} -if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; + // Moral/Physic attribute + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Gender").''; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); + print '
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; + print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; + print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); + print ' / '; + print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); + print '
'.$langs->trans('Country').''; + $country_id = GETPOST('country_id'); + if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + } + if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; + } } } -} -$country_code = getCountry($country_id, 2, $db, $langs); -print $form->select_country($country_id, 'country_id'); -print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } + $country_code = getCountry($country_id, 2, $db, $langs); + print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; -print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); -print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } + print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; + print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); + print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + // Add specific fields used by Dolibarr foundation for example + if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print '
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; - print ''; - print '
'.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; + print "
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; } - print ' '.$langs->trans("Currency".$conf->currency); - print '
\n"; - -print dol_get_fiche_end(); - -// Save -print '
'; -print ''; -if (!empty($backtopage)) { - print '     '; -} -print '
'; + print '
'; -print "\n"; -print "
"; -print ''; + print "\n"; + print "
"; + print ''; -llxFooterVierge(); + llxFooterVierge(); -$db->close(); + $db->close(); From 5a8742b3ebe313c14565e0944527777e1b100df9 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Sat, 17 Apr 2021 13:25:28 +0100 Subject: [PATCH 092/928] Cancel Partnership For Expired Members & Warning of partnership if Dolibarr backlink not found on partner website --- htdocs/core/modules/modPartnership.class.php | 6 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 13 +- htdocs/langs/en_US/partnership.lang | 6 +- htdocs/partnership/admin/setup.php | 59 ++- .../partnership/class/partnership.class.php | 5 +- .../class/partnershiputils.class.php | 420 +++++++++++++++++- htdocs/partnership/partnership_list.php | 6 +- 7 files changed, 474 insertions(+), 41 deletions(-) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index ae5886e589c..0d5d6dce7ca 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -177,7 +177,7 @@ class modPartnership extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; + $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); @@ -253,12 +253,12 @@ class modPartnership extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $statusatinstall=0; $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>$statusatinstall, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'WarningOfPartnershipIfDolibarrBacklinkNotfound', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index c1e75bbe353..d0375349880 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -398,8 +398,9 @@ CREATE TABLE llx_partnership( note_private text, note_public text, last_main_doc varchar(255), - count_last_url_check_error integer DEFAULT '0', - import_key varchar(14), + count_last_url_check_error integer DEFAULT '0', + last_check_backlink datetime NULL, + import_key varchar(14), model_pdf varchar(255) ) ENGINE=innodb; @@ -420,10 +421,10 @@ create table llx_partnership_extrafields ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonExpireContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonExpireContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email; ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 4d5b518431f..2da278dd36c 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -32,7 +32,10 @@ ListOfPartnerships=List of partnership PartnershipSetup=Partnership setup PartnershipAbout=About Partnership PartnershipAboutPage=Partnership about page -PartnershipManagedFor=Partnership managed for +partnershipforthirdpartyormember=Partnership is for a 'thirdparty' or for a 'member' +PARTNERSHIP_IS_MANAGED_FOR=Partnership managed for +PARTNERSHIP_BACKLINKS_TO_CHECK=Backlinks to check +PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cancel status of partnership # # Object @@ -44,6 +47,7 @@ ReasonDecline=Decline reason ReasonDeclineOrCancel=Decline reason PartnershipAlreadyExist=Partnership already exist ShowPartnership=Show partnership +BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? # diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 77edba1f21f..4cd5fe5f387 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -82,9 +82,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setting') { require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php"; - $value = GETPOST('managed_for', 'alpha'); - - $modulemenu = ($value == 'member') ? 'member' : 'thirdparty'; + $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty'; $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity); $partnership = new modPartnership($db); @@ -94,6 +92,10 @@ if ($action == 'setting') { $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); + + if(GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int')) + dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } if ($action) { @@ -102,6 +104,8 @@ if ($action) { } else { setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } + header("Location: ".$_SERVER['PHP_SELF']); + exit; } /* @@ -137,19 +141,48 @@ print ''; print ''; -// Default partnership price base type -print ''; -print ''; -print ''; + +print ''; +print ''; +print ''; +print ''; print ''; -print '
'.$langs->trans("PartnershipManagedFor").''; - print ''; -print '
'.$langs->trans("Setting").''.$langs->trans("Value").''.$langs->trans("Examples").'
'; +print ''.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").''; +print ''; +print ''; +print ''; +print ''.$langs->trans("partnershipforthirdpartyormember").''; +print ''; + + +if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member'){ + print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; + print ''; + $dnbdays = '7'; + $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; + print ''; + print ''; + print ''.$dnbdays.''; + print ''; +} + + +print ''.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").''; +print ''; +$dbacklinks = 'dolibarr.org|dolibarr.fr|dolibarr.es'; +$backlinks = (!empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK)) ? $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK : $dbacklinks; +print ''; +print ''; +print ''.$dbacklinks.''; +print ''; + + +print ''; print '
'; print ''; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index fd0233d3fef..6bf84ba38cc 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -118,6 +118,7 @@ class Partnership extends CommonObject public $date_partnership_start; public $date_partnership_end; public $count_last_url_check_error; + public $last_check_backlink; public $reason_decline_or_cancel; // END MODULEBUILDER PROPERTIES @@ -186,6 +187,7 @@ class Partnership extends CommonObject 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>$langs->trans('Draft'), '1'=>$langs->trans('Accepted'), '2'=>$langs->trans('Refused'), '9'=>$langs->trans('Canceled')),), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), ); @@ -361,7 +363,7 @@ class Partnership extends CommonObject $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; $sql .= ', p.note_private, p.note_public'; - $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.reason_decline_or_cancel'; + $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel'; $sql .= ', p.import_key, p.model_pdf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; @@ -407,6 +409,7 @@ class Partnership extends CommonObject $this->note_public = $obj->note_public; $this->last_main_doc = $obj->last_main_doc; $this->count_last_url_check_error = $obj->count_last_url_check_error; + $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink); $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel; $this->import_key = $obj->import_key; $this->model_pdf = $obj->model_pdf; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 08c61b3454c..64fd0f62431 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -26,9 +26,13 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + dol_include_once('partnership/lib/partnership.lib.php'); +dol_include_once('/partnership/class/partnership.class.php'); - +require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; /** * Class with cron tasks of Partnership module */ @@ -49,34 +53,422 @@ class PartnershipUtils $this->db = $db; return 1; } - - + /** - * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of cancel per call = $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) + * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) * * CAN BE A CRON TASK * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function doCancelStatusOfPartnership() + public function doCancelStatusOfMemberPartnership() { global $conf, $langs, $user; - $langs->load("agenda"); + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) ? 100 : $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL); // Limit to 100 per call + if($managedfor != 'member'){ + return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. + } - $error = 0; - $this->output = ''; - $this->error=''; + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + + $langs->loadLangs(array("partnership", "member")); + + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) + { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); + + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + + $this->db->begin(); + + $sql = "SELECT p.rowid, p.fk_member, p.status"; + $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; + $sql .= " WHERE fk_member > 0"; + $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= $this->db->order('d.rowid','ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) + { + $numofexpiredmembers = $this->db->num_rows($resql); + + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) + { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) + { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) + { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); + break; + } + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + // Get expiration date + $expirationdate = $obj->datefin; + + if ($expirationdate && $expirationdate < $now) // If contract expired (we already had a test into main select, this is a security) + { + $somethingdoneonpartnership++; + + $result = $object->cancel($user, 0); + // $conf->global->noapachereload = null; + if ($result < 0) + { + $error++; + $this->error = $object->error; + if (is_array($object->errors) && count($object->errors)) { + if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); + else $this->errors = $object->errors; + } + } + else + { + $partnershipsprocessed[$object->id]=$object->ref; + + // Send an email to inform member + $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + + dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $adherent = new Adherent($this->db); + $adherent->fetch($object->fk_member); + $to = $adherent->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) + { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + + } + } + } + } + else + { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) + { + $this->db->commit(); + $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } + else + { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } + + return ($error ? 1: 0); + } - dol_syslog(__METHOD__." we cancel status of partnership ", LOG_DEBUG); + /** + * Action executed by scheduler to check if Dolibarr backlink not found on partner website. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) + * + * CAN BE A CRON TASK + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doWarningOfPartnershipIfDolibarrBacklinkNotfound() + { + global $conf, $langs, $user; - $now = dol_now(); + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - // En cours de traitement ... + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call - return ($error ? 1: 0); + $langs->loadLangs(array("partnership", "member")); + + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) + { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; + + dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); + + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + + $this->db->begin(); + + $sql = "SELECT p.rowid, p.status, p.".$fk_partner; + $sql .= ", p.last_check_backlink"; + + $sql .= ', partner.url, partner.email'; + + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + + if ($managedfor == 'member') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; + } else { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; + } + + $sql .= " WHERE 1 = 1"; + $sql .= " AND p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= $this->db->order('p.rowid','ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) + { + $numofexpiredmembers = $this->db->num_rows($resql); + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) + { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) + { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) + { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + break; + } + + $backlinkfound = 0; + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + if($managedfor == 'member'){ + $fk_partner = $object->fk_member; + }else{ + $fk_partner = $object->fk_soc; + } + + $website = $obj->url; + + if(empty($website)){ + $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; + } else { + $backlinkfound = $this->checkDolibarrBacklink($website); + } + + if(!$backlinkfound){ + $tmpcount = $object->count_last_url_check_error + 1; + + if($tmpcount == 3){ // Send Warning Email + + if (!empty($obj->email)){ + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + + } else { + + $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; + + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $to = $obj->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) + { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + + + } elseif($tmpcount > 4) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); + } + + $object->count_last_url_check_error = $tmpcount; + + } else { + $object->count_last_url_check_error = 0; + $object->reason_decline_or_cancel = ''; + } + + $partnershipsprocessed[$object->id]=$object->ref; + + $object->last_check_backlink = $this->db->idate($now); + + $object->update($user); + } + } + } + else + { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) + { + $this->db->commit(); + $this->output = $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } + else + { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } + + return ($error ? 1: 0); + } + + /** + * Action to check if Dolibarr backlink not found on partner website + * + * CAN BE A CRON TASK + * + * @return int 0 if KO, 1 if OK + */ + public function checkDolibarrBacklink($website = null) + { + global $conf, $langs, $user; + + $found = 0; + $error = 0; + $webcontent = ''; + + // $website = 'https://nextgestion.com/'; // For Test + $tmpgeturl = getURLContent($website); + if ($tmpgeturl['curl_error_no']) { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } elseif ($tmpgeturl['http_code'] != '200') { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } else { + $urlContent = $tmpgeturl['content']; + $dom = new DOMDocument(); + @$dom->loadHTML($urlContent); + + $xpath = new DOMXPath($dom); + $hrefs = $xpath->evaluate("//a"); + + for($i = 0; $i < $hrefs->length; $i++){ + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + $url = filter_var($url, FILTER_SANITIZE_URL); + if(!filter_var($url, FILTER_VALIDATE_URL) === false){ + $webcontent .= $url; + } + } + } + + if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) + { + $found = 1; + } + + return $found; } } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 5ded7ae0047..1ae90d0d4cf 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -496,9 +496,9 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"), + 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"), ); if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); From d6085fb68a1214dcfd116fe8bbf8bcb80dc0f99b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:29:02 +0200 Subject: [PATCH 093/928] Update new.php --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 0920e5976b1..dcf64ed7634 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,7 +218,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname') { + if (!GETPOST('firstname')) ä{ $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } From d23e74660912b0b712f249d6eadc8c5089ba2e08 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 12:29:23 +0000 Subject: [PATCH 094/928] Fixing style errors. --- htdocs/public/members/new.php | 172 +++++++++++++++++----------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index dcf64ed7634..13705796ad5 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,17 +218,17 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname')) ä{ + if (!GETPOST('firstname')) { ä $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; -} -if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; -} + } + if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; + } $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - if GETPOSTISSET('birthmonth') && empty($birthday)) { + if GETPOSTISSET('birthmonth') { && empty($birthday)) $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; @@ -548,33 +548,33 @@ jQuery(document).ready(function () { print ''."\n"; // Type - if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; - } else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; +if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; } + print ''."\n"; +} else { + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; +} // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; - } else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; - } +if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print ''."\n"; +} else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; +} // Civility print ''."\n"; @@ -602,39 +602,39 @@ jQuery(document).ready(function () { // Country print ''; // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; +if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; +} // EMail print ''."\n"; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - } +if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; +} // Birthday print ''."\n"; // Add specific fields used by Dolibarr foundation for example - if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; + print ''."\n"; +} +if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount + + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - // Set amount for the subscription - $amount = isset($amount) ? $amount : 0; - - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); - } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''; + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; +} print "
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans('UserTitle').''; print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans('Country').''; $country_id = GETPOST('country_id'); - if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); - } - if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; - } +if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); +} +if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; } } +} $country_code = getCountry($country_id, 2, $db, $langs); print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } - print '
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); } + print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); @@ -653,13 +653,13 @@ jQuery(document).ready(function () { print '
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; +if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print '
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; - print ''; - print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; - } - print ' '.$langs->trans("Currency".$conf->currency); - print '
'.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print '
\n"; print dol_get_fiche_end(); @@ -726,9 +726,9 @@ jQuery(document).ready(function () { // Save print '
'; print ''; - if (!empty($backtopage)) { - print '     '; - } +if (!empty($backtopage)) { + print '     '; +} print '
'; From 973ea370e8d23a95c091fc4312e2f3b88831af34 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Sat, 17 Apr 2021 13:38:23 +0100 Subject: [PATCH 095/928] Fixing errors --- htdocs/core/modules/modPartnership.class.php | 4 ++-- htdocs/partnership/class/partnershiputils.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 0d5d6dce7ca..d70b626a99b 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -177,7 +177,7 @@ class modPartnership extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; + $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); @@ -258,7 +258,7 @@ class modPartnership extends DolibarrModules $this->cronjobs = array( 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), - 1 => array('priority'=>61, 'label'=>'WarningOfPartnershipIfDolibarrBacklinkNotfound', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'CheckDolibarrBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 64fd0f62431..6ed76518b42 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -427,7 +427,7 @@ class PartnershipUtils * Action to check if Dolibarr backlink not found on partner website * * CAN BE A CRON TASK - * + * @param $website Partner's website * @return int 0 if KO, 1 if OK */ public function checkDolibarrBacklink($website = null) From 48dffaaa537474399ddf631c6b90bebfd0482d20 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 13:30:56 +0000 Subject: [PATCH 096/928] Fixing style errors. --- htdocs/partnership/admin/setup.php | 6 +- .../class/partnershiputils.class.php | 530 ++++++++---------- 2 files changed, 251 insertions(+), 285 deletions(-) diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 4cd5fe5f387..f388c184517 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -93,8 +93,8 @@ if ($action == 'setting') { $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); - if(GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int')) - dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int'), 'chaine', 0, '', $conf->entity); + if (GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int')) + dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } @@ -160,7 +160,7 @@ print ''.$langs->trans("partnershipforthirdparty print ''; -if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member'){ +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; print ''; $dnbdays = '7'; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 64fd0f62431..13616c32804 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; dol_include_once('partnership/lib/partnership.lib.php'); dol_include_once('/partnership/class/partnership.class.php'); -require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); +require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; /** * Class with cron tasks of Partnership module @@ -53,7 +53,7 @@ class PartnershipUtils $this->db = $db; return 1; } - + /** * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) * @@ -65,163 +65,147 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - if($managedfor != 'member'){ + if ($managedfor != 'member') { return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. } - $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call - $langs->loadLangs(array("partnership", "member")); + $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; - $partnershipsprocessed = array(); + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; - if ($gracedelay < 1) - { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; - return -1; - } + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } - dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); + dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); - $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); - $this->db->begin(); + $this->db->begin(); - $sql = "SELECT p.rowid, p.fk_member, p.status"; - $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; + $sql = "SELECT p.rowid, p.fk_member, p.status"; + $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; $sql .= " WHERE fk_member > 0"; $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; - $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled - $sql .= $this->db->order('d.rowid','ASC'); - // Limit is managed into loop later + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= $this->db->order('d.rowid', 'ASC'); + // Limit is managed into loop later - $resql = $this->db->query($sql); - if ($resql) - { - $numofexpiredmembers = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); - $somethingdoneonpartnership = 0; - $ifetchpartner = 0; - while ($ifetchpartner < $numofexpiredmembers) - { - $ifetchpartner++; + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; - $obj = $this->db->fetch_object($resql); - if ($obj) - { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; - if ($somethingdoneonpartnership >= $MAXPERCALL) - { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); - break; - } + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); + break; + } - $object = new Partnership($this->db); - $object->fetch($obj->rowid); + $object = new Partnership($this->db); + $object->fetch($obj->rowid); - // Get expiration date - $expirationdate = $obj->datefin; + // Get expiration date + $expirationdate = $obj->datefin; - if ($expirationdate && $expirationdate < $now) // If contract expired (we already had a test into main select, this is a security) - { - $somethingdoneonpartnership++; + if ($expirationdate && $expirationdate < $now) { // If contract expired (we already had a test into main select, this is a security) + $somethingdoneonpartnership++; - $result = $object->cancel($user, 0); - // $conf->global->noapachereload = null; - if ($result < 0) - { - $error++; - $this->error = $object->error; - if (is_array($object->errors) && count($object->errors)) { - if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); - else $this->errors = $object->errors; - } - } - else - { - $partnershipsprocessed[$object->id]=$object->ref; + $result = $object->cancel($user, 0); + // $conf->global->noapachereload = null; + if ($result < 0) { + $error++; + $this->error = $object->error; + if (is_array($object->errors) && count($object->errors)) { + if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); + else $this->errors = $object->errors; + } + } else { + $partnershipsprocessed[$object->id]=$object->ref; - // Send an email to inform member - $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + // Send an email to inform member + $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; - dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); + dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); - } + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - $adherent = new Adherent($this->db); - $adherent->fetch($object->fk_member); - $to = $adherent->email; + $adherent = new Adherent($this->db); + $adherent->fetch($object->fk_member); + $to = $adherent->email; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (! $result || $cmail->error) - { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; - } - } - - } - } - } - } - else - { - $error++; - $this->error = $this->db->lasterror(); - } + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - if (! $error) - { - $this->db->commit(); - $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; - } - else - { - $this->db->rollback(); - $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; - } + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } - return ($error ? 1: 0); + return ($error ? 1: 0); } @@ -236,43 +220,42 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call - $langs->loadLangs(array("partnership", "member")); + $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; - $partnershipsprocessed = array(); + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; - if ($gracedelay < 1) - { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; - return -1; - } + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } - $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; + $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; - dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); + dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); - $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); - $this->db->begin(); + $this->db->begin(); - $sql = "SELECT p.rowid, p.status, p.".$fk_partner; - $sql .= ", p.last_check_backlink"; + $sql = "SELECT p.rowid, p.status, p.".$fk_partner; + $sql .= ", p.last_check_backlink"; - $sql .= ', partner.url, partner.email'; + $sql .= ', partner.url, partner.email'; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - if ($managedfor == 'member') { + if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; @@ -280,147 +263,131 @@ class PartnershipUtils $sql .= " WHERE 1 = 1"; $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled - $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. - $sql .= $this->db->order('p.rowid','ASC'); - // Limit is managed into loop later + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= $this->db->order('p.rowid', 'ASC'); + // Limit is managed into loop later - $resql = $this->db->query($sql); - if ($resql) - { - $numofexpiredmembers = $this->db->num_rows($resql); - $somethingdoneonpartnership = 0; - $ifetchpartner = 0; - while ($ifetchpartner < $numofexpiredmembers) - { - $ifetchpartner++; + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; - $obj = $this->db->fetch_object($resql); - if ($obj) - { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; - if ($somethingdoneonpartnership >= $MAXPERCALL) - { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); - break; - } + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + break; + } - $backlinkfound = 0; + $backlinkfound = 0; - $object = new Partnership($this->db); - $object->fetch($obj->rowid); + $object = new Partnership($this->db); + $object->fetch($obj->rowid); - if($managedfor == 'member'){ - $fk_partner = $object->fk_member; - }else{ - $fk_partner = $object->fk_soc; - } + if ($managedfor == 'member') { + $fk_partner = $object->fk_member; + } else { + $fk_partner = $object->fk_soc; + } - $website = $obj->url; + $website = $obj->url; - if(empty($website)){ - $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; - } else { - $backlinkfound = $this->checkDolibarrBacklink($website); - } + if (empty($website)) { + $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; + } else { + $backlinkfound = $this->checkDolibarrBacklink($website); + } - if(!$backlinkfound){ - $tmpcount = $object->count_last_url_check_error + 1; + if (!$backlinkfound) { + $tmpcount = $object->count_last_url_check_error + 1; - if($tmpcount == 3){ // Send Warning Email + if ($tmpcount == 3) { // Send Warning Email + if (!empty($obj->email)) { + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + } else { + $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; - if (!empty($obj->email)){ - $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); - } else { + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); - $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } - dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); - } + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $to = $obj->email; - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } elseif ($tmpcount > 4) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); + } - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $object->count_last_url_check_error = $tmpcount; + } else { + $object->count_last_url_check_error = 0; + $object->reason_decline_or_cancel = ''; + } - $to = $obj->email; + $partnershipsprocessed[$object->id]=$object->ref; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (! $result || $cmail->error) - { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; - } - } + $object->last_check_backlink = $this->db->idate($now); + $object->update($user); + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - } elseif($tmpcount > 4) { // Cancel Partnership - $object->status = $object::STATUS_CANCELED; - $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); - } + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } - $object->count_last_url_check_error = $tmpcount; - - } else { - $object->count_last_url_check_error = 0; - $object->reason_decline_or_cancel = ''; - } - - $partnershipsprocessed[$object->id]=$object->ref; - - $object->last_check_backlink = $this->db->idate($now); - - $object->update($user); - } - } - } - else - { - $error++; - $this->error = $this->db->lasterror(); - } - - if (! $error) - { - $this->db->commit(); - $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; - } - else - { - $this->db->rollback(); - $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; - } - - return ($error ? 1: 0); + return ($error ? 1: 0); } /** @@ -439,8 +406,8 @@ class PartnershipUtils $webcontent = ''; // $website = 'https://nextgestion.com/'; // For Test - $tmpgeturl = getURLContent($website); - if ($tmpgeturl['curl_error_no']) { + $tmpgeturl = getURLContent($website); + if ($tmpgeturl['curl_error_no']) { $error++; dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); } elseif ($tmpgeturl['http_code'] != '200') { @@ -454,19 +421,18 @@ class PartnershipUtils $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("//a"); - for($i = 0; $i < $hrefs->length; $i++){ - $href = $hrefs->item($i); - $url = $href->getAttribute('href'); - $url = filter_var($url, FILTER_SANITIZE_URL); - if(!filter_var($url, FILTER_VALIDATE_URL) === false){ - $webcontent .= $url; - } + for ($i = 0; $i < $hrefs->length; $i++) { + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + $url = filter_var($url, FILTER_SANITIZE_URL); + if (!filter_var($url, FILTER_VALIDATE_URL) === false) { + $webcontent .= $url; + } } - } - - if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) - { - $found = 1; + } + + if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) { + $found = 1; } return $found; From 16dfde112806d813c9c5718d2a63bb0756fa88fa Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:39:14 +0200 Subject: [PATCH 097/928] Update new.php --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 13705796ad5..fa9c844288f 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,7 +218,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname')) { ä + if (!GETPOST('firstname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } From b96d3cebda23f09b1581a56ca17143ccf01df672 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:51:05 +0200 Subject: [PATCH 098/928] Update new.php --- htdocs/public/members/new.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index fa9c844288f..677e1e1b906 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -227,8 +227,8 @@ if (empty($reshook) && $action == 'add') { $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; } - $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - if GETPOSTISSET('birthmonth') { && empty($birthday)) + $birthday = dol_mktime(GETPOST('birthhour', 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); + if (GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; From 17c2b4f0e8336731713250497adba37872da1f36 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 23:58:00 +0200 Subject: [PATCH 099/928] Fix warning wrong date format for new member form Fix warning wrong date format for new member form when new membre submit no birthdate --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index e6b7a3e7a38..349943c7978 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -228,7 +228,7 @@ if (empty($reshook) && $action == 'add') { $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST("birthmin", 'int'), GETPOST("birthsec", 'int'), GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); - if (GETPOSTISSET("birthmonth") && empty($birthday)) { + if (GETPOST("birthmonth") && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; From 7794927a64218d67849f0738557b4a6a6bec345d Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 18 Apr 2021 20:12:24 +0200 Subject: [PATCH 100/928] New check update for modules --- htdocs/admin/modules.php | 33 ++++++----- htdocs/core/lib/functions.lib.php | 17 +++++- htdocs/core/modules/DolibarrModules.class.php | 58 ++++++++++++++++++- htdocs/langs/en_US/admin.lang | 5 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/theme/eldy/btn.inc.php | 5 ++ htdocs/theme/eldy/info-box.inc.php | 8 ++- htdocs/theme/md/info-box.inc.php | 4 +- 8 files changed, 106 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index fbe1ae98619..8380756bee5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -518,11 +518,13 @@ if ($mode == 'common' || $mode == 'commonkanban') { print $deschelp; - $moreforfilter = '
'; + $moreforfilter = '
'; - $moreforfilter .= '