Skip to content

Commit

Permalink
NEW : can choose lines while creating order from origin
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-maxime committed Jul 8, 2019
1 parent 4387d40 commit 9c47cb6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions htdocs/commande/card.php
Expand Up @@ -232,6 +232,7 @@
{
$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');
Expand Down Expand Up @@ -338,6 +339,8 @@

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);
Expand Down Expand Up @@ -1870,8 +1873,6 @@
print '<input type="button" class="button" name="cancel" value="' . $langs->trans("Cancel") . '" onclick="javascript:history.go(-1)">';
print '</div>';

print '</form>';

// Show origin lines
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
$title = $langs->trans('ProductsAndServices');
Expand All @@ -1883,6 +1884,8 @@

print '</table>';
}

print '</form>';
} else {
// Mode view
$now = dol_now();
Expand Down
11 changes: 7 additions & 4 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -4145,7 +4145,7 @@ public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $
*/
public function printOriginLinesList($restrictlist = '')
{
global $langs, $hookmanager, $conf;
global $langs, $hookmanager, $conf, $form;

print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
Expand All @@ -4158,8 +4158,9 @@ public function printOriginLinesList($restrictlist = '')
{
print '<td class="left">'.$langs->trans('Unit').'</td>';
}
print '<td class="right">'.$langs->trans('ReductionShort').'</td></tr>';

print '<td class="right">'.$langs->trans('ReductionShort').'</td>';
print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
print '</tr>';
$var = true;
$i = 0;

Expand Down Expand Up @@ -4200,7 +4201,7 @@ public function printOriginLinesList($restrictlist = '')
*/
public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl')
{
global $langs, $conf;
global $langs, $conf, $selectedLines;

//var_dump($line);
if (!empty($line->date_start))
Expand All @@ -4222,6 +4223,8 @@ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir
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');

Expand Down
4 changes: 4 additions & 0 deletions htdocs/core/tpl/originproductline.tpl.php
Expand Up @@ -40,6 +40,10 @@
print '<td class="left">'.$langs->trans($this->tpl['unit']).'</td>';

print '<td class="right">'.$this->tpl['remise_percent'].'</td>';

$selected=1;
if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
print '<td class="center"><input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'></td>';
print '</tr>'."\n";
?>
<!-- END PHP TEMPLATE originproductline.tpl.php -->

0 comments on commit 9c47cb6

Please sign in to comment.