diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 85d5de2e322..51cdb342dc3 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -532,7 +532,7 @@ class BOM extends CommonObject $error = 0; // Protection - if ($this->statut == self::STATUS_VALIDATED) + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index d3c15dc3f68..7f4cdb9c7bb 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -466,9 +466,11 @@ CREATE TABLE llx_mrp_mo( note_public text, note_private text, date_creation datetime NOT NULL, + date_valid datetime NULL, tms timestamp, fk_user_creat integer NOT NULL, fk_user_modif integer, + fk_user_valid integer, model_pdf varchar(255), import_key varchar(14), status integer NOT NULL, @@ -480,6 +482,9 @@ CREATE TABLE llx_mrp_mo( -- END MODULEBUILDER FIELDS ) ENGINE=innodb; +ALTER TABLE llx_mrp_mo ADD COLUMN date_valid datetime NULL; +ALTER TABLE llx_mrp_mo ADD COLUMN fk_user_valid integer; + ALTER TABLE llx_bom_bom ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_mrp_mo ADD COLUMN model_pdf varchar(255); diff --git a/htdocs/install/mysql/tables/llx_mrp_mo.sql b/htdocs/install/mysql/tables/llx_mrp_mo.sql index 19f48e27e8a..d3aa294104b 100644 --- a/htdocs/install/mysql/tables/llx_mrp_mo.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) 2019 Laurent Destailleur -- -- 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 @@ -26,9 +26,11 @@ CREATE TABLE llx_mrp_mo( note_public text, note_private text, date_creation datetime NOT NULL, + date_valid datetime NULL, tms timestamp, fk_user_creat integer NOT NULL, - fk_user_modif integer, + fk_user_modif integer, + fk_user_valid integer, import_key varchar(14), model_pdf varchar(255), status integer NOT NULL, diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 4bed22df445..e5bcb1e5318 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -50,7 +50,12 @@ BomAndBomLines=Bills Of Material and lines BOMLine=Line of BOM WarehouseForProduction=Warehouse for production CreateMO=Create MO -ToConsume=A consommer -Manufactured=Fabriqué +ToConsume=To consume +ToProduce=To produce +QtyAlreadyConsumed=Qty already consumed +QtyAlreadyProduced=Qty already produced +ConsumeAndProduceAll=Consume and Produce All +Manufactured=Manufactured TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce. -ForAQuantityOf1=For a quantity to produce of 1 \ No newline at end of file +ForAQuantityOf1=For a quantity to produce of 1 +ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index fe3731b2b40..8801ff6771c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -514,7 +514,7 @@ class MyObject extends CommonObject $error = 0; // Protection - if ($this->statut == self::STATUS_VALIDATED) + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index c69293b2e49..7b4a2abc50d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -499,13 +499,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* if ($permissiontoadd) { - if ($object->status == 1) + if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; + print ''.$langs->trans("Disable").''."\n"; } else { - print ''.$langs->trans("Enable").''."\n"; + print ''.$langs->trans("Enable").''."\n"; + } + } + if ($permissiontoadd) + { + if ($object->status == $object::STATUS_VALIDATED) + { + print ''.$langs->trans("Cancel").''."\n"; + } + else + { + print ''.$langs->trans("Re-Open").''."\n"; } } */ diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 49c5bed3dda..c338ad4c774 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -92,10 +92,10 @@ class Mo extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1,), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce"), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce",), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), @@ -250,7 +250,7 @@ class Mo extends CommonObject $error++; } - // Insert lines in mrp_production table + // Insert lines in mrp_production table from BOM data if (!$error && $this->fk_bom > 0) { include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; @@ -258,32 +258,52 @@ class Mo extends CommonObject $bom->fetch($this->fk_bom); if ($bom->id > 0) { - foreach ($bom->lines as $line) - { - $moline = new MoLine($this->db); + $moline = new MoLine($this->db); - $moline->fk_mo = $this->id; - $moline->qty = $line->qty * $this->qty * $bom->efficiency; - if ($moline->qty <= 0) { - $error++; - $this->error = "BadValueForquantityToConsume"; - break; - } - else { - $moline->fk_product = $line->fk_product; - $moline->role = 'toconsume'; - $moline->position = $line->position; - $moline->qty_frozen = $line->qty_frozen; - $moline->disable_stock_change = $line->disable_stock_change; + // Line to produce + $moline->fk_mo = $this->id; + $moline->qty = $this->qty; + $moline->fk_product = $this->fk_product; + $moline->role = 'toproduce'; + $moline->position = 1; - $resultline = $moline->create($user); - if ($resultline <= 0) { + $resultline = $moline->create($user); + if ($resultline <= 0) { + $error++; + $this->error = $moline->error; + $this->errors = $moline->errors; + dol_print_error($this->db, $moline->error, $moline->errors); + } + + // Lines to consume + if (! $error) { + foreach ($bom->lines as $line) + { + $moline = new MoLine($this->db); + + $moline->fk_mo = $this->id; + $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); + if ($moline->qty <= 0) { $error++; - $this->error = $moline->error; - $this->errors = $moline->errors; - dol_print_error($this->db, $moline->error, $moline->errors); + $this->error = "BadValueForquantityToConsume"; break; } + else { + $moline->fk_product = $line->fk_product; + $moline->role = 'toconsume'; + $moline->position = $line->position; + $moline->qty_frozen = $line->qty_frozen; + $moline->disable_stock_change = $line->disable_stock_change; + + $resultline = $moline->create($user); + if ($resultline <= 0) { + $error++; + $this->error = $moline->error; + $this->errors = $moline->errors; + dol_print_error($this->db, $moline->error, $moline->errors); + break; + } + } } } } @@ -540,6 +560,193 @@ class Mo extends CommonObject return $this->deleteLineCommon($user, $idline, $notrigger); } + + /** + * Returns the reference to the following non used MO depending on the active numbering module + * defined into MRP_MO_ADDON + * + * @param Product $prod Object product + * @return string MO free reference + */ + public function getNextNumRef($prod) + { + global $langs, $conf; + $langs->load("mrp"); + + if (!empty($conf->global->MRP_MO_ADDON)) + { + $mybool = false; + + $file = $conf->global->MRP_MO_ADDON.".php"; + $classname = $conf->global->MRP_MO_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/mrp/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = $obj->getNextValue($prod, $this); + + if ($numref != "") + { + return $numref; + } + else + { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_MRP_MO_ADDON_NotDefined"); + return ""; + } + } + + /** + * Validate Mo + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) + { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mrp->create)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mrp->mrp_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + { + $this->fetch_product(); + $num = $this->getNextNumRef($this->product); + } + else + { + $num = $this->ref; + } + $this->newref = $num; + + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED.","; + $sql .= " date_valid='".$this->db->idate($now)."',"; + $sql .= " fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('MRP_MO_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (!$error) + { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'mrp/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'mrp/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->mrp->dir_output.'/'.$oldref; + $dirdest = $conf->mrp->dir_output.'/'.$newref; + if (!$error && file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->mrp->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) + { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + /** * Return a link to the object card (with optionaly the picto) * @@ -824,19 +1031,19 @@ class Mo extends CommonObject { foreach ($this->lines as $line) { - if (is_object($hookmanager)) + /*if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) { $parameters = array('line'=>$line, 'i'=>$i); $action = ''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $result = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } else - { + {*/ $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); - } + //} $i++; } @@ -873,7 +1080,7 @@ class Mo extends CommonObject } else { - // If origin BOM line is not a product, but another BOM + // If origin MRP line is not a product, but another MRP // TODO } diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 6fa86a34b76..c290601163d 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -139,7 +139,7 @@ if (empty($reshook)) } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record - // Actions cancel, add, update, delete or clone + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; // Actions when linking object each other @@ -361,7 +361,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $object->fetch_product(); - $numref = $object->getNextNumRef($object->thirdparty); + $numref = $object->getNextNumRef($object->fk_product); } else { $numref = $object->ref; } @@ -487,7 +487,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { // Show object lines - $result = $object->getLinesArray(); + //$result = $object->getLinesArray(); + $object->fetchLines(); print '
@@ -496,42 +497,61 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + /*if (!empty($conf->use_javascript_ajax) && $object->status == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } + }*/ - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines)) { - print ''; + print '
'; + print '
'; - print ''; - } + print ''; + print ''; + print ''; + print ''; - /*if (!empty($object->lines)) - { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl'); - } + print ''; + print ''; + print ''; + print ''; - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') - { - if ($action != 'editline') - { - // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc, '/mrp/tpl'); + print ''; + print ''; + print ''; + print ''; - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } */ - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) - { print '
TODO...
'.$langs->trans("Summary").'
'.$langs->trans("ToConsume").''; + if (!empty($object->lines)) + { + $i = 0; + foreach($object->lines as $line) { + if ($line->role == 'toconsume') { + if ($i) print ', '; + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + print $tmpproduct->getNomUrl(1); + $i++; + } + } + } + print '
'.$langs->trans("ToProduce").''; + if (!empty($object->lines)) + { + $i = 0; + foreach($object->lines as $line) { + if ($line->role == 'toproduce') { + if ($i) print ', '; + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + print $tmpproduct->getNomUrl(1); + $i++; + } + } + } + print '
'; + print '
'; } - print ''; - print "
\n"; } @@ -551,22 +571,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //print '' . $langs->trans('SendMail') . ''."\n"; // Back to draft - if ($object->status == $object::STATUS_VALIDATED) + /*if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { print ''.$langs->trans("SetToDraft").''; } - } + }*/ // Modify - if ($permissiontoadd) - { - print ''.$langs->trans("Modify").''."\n"; - } - else - { - print ''.$langs->trans('Modify').''."\n"; + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } } // Validate @@ -591,10 +613,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans("ToClone").''; } + // Cancel + if ($permissiontoadd) + { + if ($object->status == $object::STATUS_VALIDATED) + { + print ''.$langs->trans("Cancel").''."\n"; + } + else + { + print ''.$langs->trans("Re-Open").''."\n"; + } + } + // Delete (need delete permission, or if draft, just need create/modify permission) if ($permissiontodelete) { - print ''.$langs->trans('Delete').''."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index d268b5e1a6b..064f9f07d37 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -99,6 +99,7 @@ $permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; +$permissiontoproduce = $permissiontoadd; /* * Actions @@ -305,6 +306,49 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea dol_fiche_end(); + print '
'; + + $parameters = array(); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); + if (empty($reshook)) { + // Consume + + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('Consume').''; + } else { + print ''.$langs->trans('Consume').''; + } + } else { + print ''.$langs->trans('Consume').''; + } + + // Produce + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('Produce').''; + } else { + print ''.$langs->trans('Produce').''; + } + } else { + print ''.$langs->trans('Produce').''; + } + + // ConsumeAndProduceAll + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('ConsumeAndProduceAll').''; + } else { + print ''.$langs->trans('ConsumeAndProduceAll').''; + } + } else { + print ''.$langs->trans('ConsumeAndProduceAll').''; + } + } + + print '
'; + /* * Lines @@ -313,7 +357,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { // Show object lines - $result = $object->getLinesArray(); + //$result = $object->getLinesArray(); + $object->fetchLines(); print '
@@ -326,16 +371,44 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } - $object->fetchLines(); + print '
'; + print '
'; + print '
'; + + print load_fiche_titre($langs->trans('Consumption'), '', ''); print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + print ''; + + print ''; + print ''; + print ''; + print ''; + /*print ''; + print '';*/ + print ''; + + if (!empty($object->lines)) { - print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyConsumed").''.$langs->trans("Date").''.$langs->trans("Batch").'
'; + foreach($object->lines as $line) { + if ($line->role == 'toconsume') { + print ''; + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + print ''; + print ''; + $alreadyconsumed = 0; + print ''; + /*print ''; + print '';*/ + print ''; - print ''; + // Show detailed of already consumed + //$arrayoflines = $line->fetchLinesLinked('consumed'); - //var_dump($object->lines); + + } + } } /*if (!empty($object->lines)) @@ -356,10 +429,53 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } }*/ - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + print '
'.$tmpproduct->getNomUrl(1).''.$line->qty.''.$alreadyconsumed.''.''.'
TODO...
'; + print '
'; + + print '
'; + print '
'; + print '
'; + + print load_fiche_titre($langs->trans('Production'), '', ''); + + print '
'; + print ''; + + print ''; + print ''; + print ''; + print ''; + /*print ''; + print '';*/ + print ''; + + if (!empty($object->lines)) { - print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyProduced").''.$langs->trans("Date").''.$langs->trans("Batch").'
'; + foreach($object->lines as $line) { + if ($line->role == 'toproduce') { + print ''; + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + print ''.$tmpproduct->getNomUrl(1).''; + print ''.$line->qty.''; + $alreadyconsumed = 0; + print ''.$alreadyconsumed.''; + /*print ''.''; + print ''.'';*/ + print ''; + + // Show detailed of already consumed + //$arrayoflines = $line->fetchLinesLinked('consumed'); + + + } + } } + + print ''; + print '
'; + + print '
'; print '
'; print "
\n";