From 9c47cb6f916ed057d17ed9242139b9bd4e9e2336 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 8 Jul 2019 23:16:32 +0200 Subject: [PATCH 1/3] NEW : can choose lines while creating order from origin --- htdocs/commande/card.php | 7 +++++-- htdocs/core/class/commonobject.class.php | 11 +++++++---- htdocs/core/tpl/originproductline.tpl.php | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 7362f30e5a8..f9fd3a716f5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -232,6 +232,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $selectedLines = GETPOST('toselect'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); @@ -338,6 +339,8 @@ if (empty($reshook)) for($i = 0; $i < $num; $i ++) { + if(!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : ''); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); @@ -1870,8 +1873,6 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; - print ''; - // Show origin lines if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); @@ -1883,6 +1884,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } + + print ''; } else { // Mode view $now = dol_now(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a300476fb5..f3832ff2782 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4145,7 +4145,7 @@ abstract class CommonObject */ public function printOriginLinesList($restrictlist = '') { - global $langs, $hookmanager, $conf; + global $langs, $hookmanager, $conf, $form; print ''; print ''.$langs->trans('Ref').''; @@ -4158,8 +4158,9 @@ abstract class CommonObject { print ''.$langs->trans('Unit').''; } - print ''.$langs->trans('ReductionShort').''; - + print ''.$langs->trans('ReductionShort').''; + print ''.$form->showCheckAddButtons('checkforselect', 1).''; + print ''; $var = true; $i = 0; @@ -4200,7 +4201,7 @@ abstract class CommonObject */ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') { - global $langs, $conf; + global $langs, $conf, $selectedLines; //var_dump($line); if (!empty($line->date_start)) @@ -4222,6 +4223,8 @@ abstract class CommonObject if ($line->date_fin_reel) $date_end=$line->date_fin_reel; } + $this->tpl['id'] = $line->id; + $this->tpl['label'] = ''; if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 2f0accd6306..e29ea678282 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -40,6 +40,10 @@ if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; + +$selected=1; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0; +print ''; print ''."\n"; ?> From 4bd806ea65b24ddda8cf8bee9a2a571e014cc567 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 27 Jul 2019 18:13:44 +0200 Subject: [PATCH 2/3] Move $selectedlines to parameter --- htdocs/commande/card.php | 2 +- htdocs/core/class/commonobject.class.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f398fe49713..28dbb52a965 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1880,7 +1880,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 43ba2499680..8881cffe659 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4142,9 +4142,10 @@ abstract class CommonObject * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects. * * @param string $restrictlist ''=All lines, 'services'=Restrict to services only + * @param array $selectedLines Array of lines id for selected lines * @return void */ - public function printOriginLinesList($restrictlist = '') + public function printOriginLinesList($restrictlist = '', $selectedLines = array()) { global $langs, $hookmanager, $conf, $form; @@ -4180,7 +4181,7 @@ abstract class CommonObject } else { - $this->printOriginLine($line, $var, $restrictlist); + $this->printOriginLine($line, $var, $restrictlist, '/core/tpl', $selectedLines); } $i++; @@ -4198,11 +4199,12 @@ abstract class CommonObject * @param string $var Var * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @param string $defaulttpldir Directory where to find the template + * @param array $selectedLines Array of lines id for selected lines * @return void */ - public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') + public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array()) { - global $langs, $conf, $selectedLines; + global $langs, $conf; //var_dump($line); if (!empty($line->date_start)) @@ -5030,7 +5032,7 @@ abstract class CommonObject //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); - + if (!empty($attrfieldcomputed)) { if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) From f9094cfc446cff82beac3b5bfdb03af4f321ddf3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:00:41 +0200 Subject: [PATCH 3/3] Update card.php --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 18d851fb628..031d2c95235 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -240,7 +240,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $selectedLines = GETPOST('toselect'); + $selectedLines = GETPOST('toselect', 'array'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');