--- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_index.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -65,3 +64,4 @@ -if ($conf->use_javascript_ajax) { - $sql = "SELECT COUNT(t.rowid) as nb, status"; - $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t"; +if ($conf->use_javascript_ajax) +{ + $sql = "SELECT COUNT(t.rowid) as nb, status"; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t"; @@ -70,8 +70,9 @@ - $resql = $db->query($sql); - - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - $totalnb = 0; - $dataseries = array(); + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $totalnb = 0; + $dataseries = array(); @@ -81,65 +82,62 @@ - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj) { - $vals[$obj->status] = $obj->nb; - - $totalnb += $obj->nb; - } - $i++; - } - $db->free($resql); - - print '
'; - print ''; - print ''."\n"; - $listofstatus = array(0, 1, 2, 3, 9); - foreach ($listofstatus as $status) { - $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Mo::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == Mo::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == Mo::STATUS_INPROGRESS) { - $colorseries[$status] = $badgeStatus4; - } - if ($status == Mo::STATUS_PRODUCED) { - $colorseries[$status] = $badgeStatus6; - } - if ($status == Mo::STATUS_CANCELED) { - $colorseries[$status] = $badgeStatus9; - } - - if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) { - print ''; - } - print "
'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'
'.$staticmo->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; - - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->SetHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb ? 0 : 1); - - print '
"; - print "
"; - - print "
"; - } else { - dol_print_error($db); - } + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $vals[$obj->status] = $obj->nb; + + $totalnb += $obj->nb; + } + $i++; + } + $db->free($resql); + + print '
'; + print ''; + print ''."\n"; + $listofstatus = array(0, 1, 2, 3, 9); + foreach ($listofstatus as $status) + { + $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Mo::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Mo::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Mo::STATUS_INPROGRESS) $colorseries[$status] = $badgeStatus4; + if ($status == Mo::STATUS_PRODUCED) $colorseries[$status] = $badgeStatus6; + if ($status == Mo::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; + } + print "
'.$langs->trans("Statistics").' - '.$langs->trans("MO").'
'.$staticmo->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb ? 0 : 1); + + print '
"; + print "
"; + + print "
"; + } + else + { + dol_print_error($db); + } @@ -151 +149 @@ -print '
'; +print '
'; @@ -159 +157 @@ -$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product"; +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; @@ -166 +164,2 @@ -if ($resql) { +if ($resql) +{ @@ -173 +172,2 @@ - if ($num) { + if ($num) + { @@ -175 +175,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -180 +180,0 @@ - $staticbom->fk_product = $obj->fk_product; @@ -198 +198,3 @@ -} else { +} +else +{ @@ -215,38 +217,42 @@ -if ($resql) { - print '
'; - print ''; - print ''; - print ''; - - $num = $db->num_rows($resql); - if ($num) { - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $staticmo->id = $obj->rowid; - $staticmo->ref = $obj->ref; - $staticmo->date_modification = $obj->datem; - $staticmo->status = $obj->status; - - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } else { - print ''; - print ''; - print ''; - } - print "
'.$langs->trans("LatestMOModified", $max).'
'.$staticmo->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmo->getLibStatut(3).'
'.$langs->trans("None").'
"; - print "
"; -} else { - dol_print_error($db); -} - -print '
'; - -$object = new stdClass(); +if ($resql) +{ + print '
'; + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $staticmo->id = $obj->rowid; + $staticmo->ref = $obj->ref; + $staticmo->date_modification = $obj->datem; + $staticmo->status = $obj->status; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } else { + print ''; + print ''; + print ''; + } + print "
'.$langs->trans("LatestMOModified", $max).'
'.$staticmo->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmo->getLibStatut(3).'
'.$langs->trans("None").'
"; + print "
"; +} +else +{ + dol_print_error($db); +} + +print ''; + @@ -254,2 +260,2 @@ - //'type' => $type, - 'user' => $user, + //'type' => $type, + 'user' => $user, @@ -257 +263 @@ -$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object); +$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters); --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_agenda.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_agenda.php @@ -16 +16 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -41 +41 @@ -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); @@ -43 +43 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -47,9 +47,9 @@ -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); -} -$search_rowid = GETPOST('search_rowid'); +if (GETPOST('actioncode', 'array')) +{ + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} @@ -58,7 +58,5 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -68,6 +66,2 @@ -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC'; -} +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC'; @@ -86,3 +80 @@ -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; -} +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; @@ -103,16 +95,17 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } @@ -132 +125,2 @@ -if ($object->id > 0) { +if ($object->id > 0) +{ @@ -134,2 +128,2 @@ - //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:|DE:Modul_Terminplanung'; + //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = ''; @@ -138,3 +132 @@ - if (isModEnabled('notification')) { - $langs->load("mails"); - } + if (!empty($conf->notification->enabled)) $langs->load("mails"); @@ -144 +136 @@ - print dol_get_fiche_head($head, 'agenda', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'agenda', $langs->trans("MO"), -1, $object->picto); @@ -155,6 +147 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -162 +149,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -164,7 +152,15 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); @@ -172 +167,0 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); @@ -177,4 +172,3 @@ - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; @@ -188,4 +182,4 @@ - print '
'; - print '
'; - - $object->info($object->id); + print '
'; + print '
'; + + $object->info($object->id); @@ -196 +190 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -202,14 +196,13 @@ - $objthirdparty = $object; - $objcon = new stdClass(); - - $out = '&origin='.$object->element.'&originid='.$object->id; - $permok = $user->hasRight('agenda', 'myactions', 'create'); - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; + $objthirdparty = $object; + $objcon = new stdClass(); + + $out = '&origin='.$object->element.'&originid='.$object->id; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; @@ -221,18 +214,19 @@ - if (isModEnabled('agenda')) { - if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - print ''.$langs->trans("AddAction").''; - } else { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - - if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { - $param = '&id='.$object->id.'&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } + if (!empty($conf->agenda->enabled)) + { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + $param = '&id='.$object->id.'&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); @@ -243 +237 @@ - // List of all actions + // List of all actions @@ -245,6 +239,5 @@ - $filters['search_agenda_label'] = $search_agenda_label; - $filters['search_rowid'] = $search_rowid; - - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } + $filters['search_agenda_label'] = $search_agenda_label; + + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_card.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_card.php @@ -2 +2 @@ -/* Copyright (C) 2017-2020 Laurent Destailleur +/* Copyright (C) 2017 Laurent Destailleur @@ -15 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -19,3 +19,3 @@ - * \file htdocs/mrp/mo_card.php - * \ingroup mrp - * \brief Page to create/edit/view MO Manufacturing Order + * \file mo_card.php + * \ingroup mrp + * \brief Page to create/edit/view mo @@ -22,0 +23,19 @@ + +//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 @@ -35,6 +53,0 @@ -require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; - -if (isModEnabled('workstation')) { - require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; -} - @@ -43,2 +56 @@ -$langs->loadLangs(array('mrp', 'other')); - +$langs->loadLangs(array("mrp", "other")); @@ -48 +60 @@ -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); @@ -50,3 +62,3 @@ -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search @@ -55,3 +67 @@ -$TBomLineId = GETPOST('bomlineid', 'array'); -$lineid = GETPOST('lineid', 'int'); -$socid = GETPOST("socid", 'int'); +//$lineid = GETPOST('lineid', 'int'); @@ -62 +71,0 @@ - @@ -73 +82 @@ -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -75,4 +84,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -81,3 +89 @@ -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; @@ -88 +94,2 @@ -if (GETPOST('fk_bom', 'int') > 0) { +if (GETPOST('fk_bom', 'int')) +{ @@ -95 +101,0 @@ - $_POST['mrptype'] = $objectbom->bomtype; @@ -107 +112,0 @@ -// Permissions @@ -121,193 +126,75 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); - - $object->oldQty = $object->qty; - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); - } - } - } - if ($cancel && !empty($backtopageforcancel)) { - $backtopage = $backtopageforcancel; - } - $triggermodname = 'MO_MODIFY'; // Name of trigger action code to execute when we modify record - - // Create MO with Childs - if ($action == 'add' && empty($id) && !empty($TBomLineId)) { - $noback = 1; - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - $mo_parent = $object; - - $moline = new MoLine($db); - $objectbomchildline = new BOMLine($db); - - foreach ($TBomLineId as $id_bom_line) { - $object = new Mo($db); // modified by the actions_addupdatedelete.inc.php - - $objectbomchildline->fetch($id_bom_line); - - $TMoLines = $moline->fetchAll('DESC', 'rowid', '1', '', array('origin_id' => $id_bom_line)); - - foreach ($TMoLines as $tmpmoline) { - $_POST['fk_bom'] = $objectbomchildline->fk_bom_child; - $_POST['fk_parent_line'] = $tmpmoline->id; - $_POST['qty'] = $tmpmoline->qty; - $_POST['fk_product'] = $tmpmoline->fk_product; - } - - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - $res = $object->add_object_linked('mo', $mo_parent->id); - } - - header("Location: ".dol_buildpath('/mrp/mo_card.php?id='.((int) $mo_parent->id), 1)); - exit; - } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && !empty($permissiontoadd)) { - $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); - if ($result > 0) { - header("Location: " . dol_buildpath('/mrp/mo_card.php?id=' . $object->id, 1)); - exit; - } else { - $action = ''; - setEventMessages($object->error, $object->errors, 'errors'); - } - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && !empty($permissiontodelete)) { - $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->delete($user, 0, $also_cancel_consumed_and_produced_lines); - if ($result > 0) { - header("Location: " . $backurlforlist); - exit; - } else { - $action = ''; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - if (!($object->id > 0)) { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } - - $error = 0; - $deleteChilds = GETPOST('deletechilds', 'boolean'); - - // Start the database transaction - $db->begin(); - - if ($deleteChilds === 'on') { - $TMoChildren = $object->getAllMoChilds(); - - foreach ($TMoChildren as $id => $childObject) { - if ($childObject->delete($user) == -1) { - $error++; - if (!empty($childObject->errors)) { - setEventMessages(null, $childObject->errors, 'errors'); - } else { - setEventMessages($childObject->error, null, 'errors'); - } - } - } - } - - if (!$error) { - $result = $object->delete($user); - - if ($result > 0) { - setEventMessages("RecordDeleted", null, 'mesgs'); - - if ($deleteChilds === 'on') { - setEventMessages("MoChildsDeleted", null, 'mesgs'); - } - - if (empty($noback)) { - header("Location: " . $backurlforlist); - exit; - } - } else { - $error++; - if (!empty($object->errors)) { - setEventMessages(null, $object->errors, 'errors'); - } else { - setEventMessages($object->error, null, 'errors'); - } - } - } - - // Commit or rollback the database transaction based on whether there was an error - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } - - - // 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 - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; - - // Actions when printing a doc from card - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - // Action to build doc - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - - // Actions to send emails - $triggersendname = 'MO_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; - $trackid = 'mo'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - - // Action to move up and down lines of object - //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - - // Action close produced - if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - if ($result >= 0) { - // Define output language - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, 0, 0, 0); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error = 0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } + } + if ($cancel && !empty($backtopageforcancel)) { + $backtopage = $backtopageforcancel; + } + + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // 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 + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $triggersendname = 'MO_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid = 'mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Action close produced + if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) + { + $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, 0, 0, 0); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } @@ -327,4 +214,16 @@ -$title = $langs->trans('ManufacturingOrder')." - ".$langs->trans("Card"); - -llxHeader('', $title, ''); - +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; @@ -334,8 +233,2 @@ -if ($action == 'create') { - if (GETPOST('fk_bom', 'int') > 0) { - $titlelist = $langs->trans("ToConsume"); - if ($objectbom->bomtype == 1) { - $titlelist = $langs->trans("ToObtain"); - } - } - +if ($action == 'create') +{ @@ -347,8 +240,4 @@ - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(array(), ''); + if ($backtopage) print ''; + if ($backtopageforcancel) print ''; + + dol_fiche_head(array(), ''); @@ -366,3 +255,3 @@ - print dol_get_fiche_end(); - - mrpCollapseBomManagement(); ?> + dol_fiche_end(); + + ?> @@ -370,2 +259,2 @@ - $(document).ready(function () { - jQuery('#fk_bom').change(function() { + $(document).ready(function () { + jQuery('#fk_bom').change(function() { @@ -376 +265 @@ - window.location.href = '?action=create&token=&fk_bom='+jQuery('#fk_bom').val(); + window.location.href = '?action=create&fk_bom='+jQuery('#fk_bom').val(); @@ -382 +270,0 @@ - console.log(data); @@ -384,2 +271,0 @@ - $("#mrptype").val(data.bomtype); // We set bomtype into mrptype - $('#mrptype').trigger('change'); // Notify any JS components that the value changed @@ -408 +294 @@ - window.location.href = '?action=create&token=&qty='+jQuery('#qty').val()+'&mrptype='+jQuery('#mrptype').val()+'&fk_product='+jQuery('#fk_product').val()+'&label='+jQuery('#label').val()+'&fk_project='+jQuery('#fk_project').val()+'&fk_warehouse='+jQuery('#fk_warehouse').val(); + window.location.href = '?action=create&qty='+jQuery('#qty').val()+'&fk_product='+jQuery('#fk_product').val()+'&label='+jQuery('#label').val()+'&fk_project='+jQuery('#fk_project').val()+'&fk_warehouse='+jQuery('#fk_warehouse').val(); @@ -419 +305 @@ - }); + }); @@ -426,6 +312,9 @@ - print $form->buttonsSaveCancel("Create"); - - if ($objectbom->id > 0) { - print load_fiche_titre($titlelist); - - print ''."\n"; + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + if (GETPOST('fk_bom', 'int') > 0) { + print load_fiche_titre($langs->trans("ToConsume")); + @@ -436 +324,0 @@ - $object->mrptype = $objectbom->bomtype; @@ -449,2 +337,3 @@ -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("ManufacturingOrder"), '', 'mrp'); +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("MO"), '', 'mrp'); @@ -453 +342 @@ - print ''; + print ''; @@ -456,8 +345,4 @@ - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(); + if ($backtopage) print ''; + if ($backtopageforcancel) print ''; + + dol_fiche_head(); @@ -477,3 +362,5 @@ - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; @@ -485 +372,2 @@ -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ @@ -486,0 +375 @@ + $res = $object->fetch_optionals(); @@ -489,2 +378 @@ - - print dol_get_fiche_head($head, 'card', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'card', $langs->trans("MO"), -1, $object->picto); @@ -495,19 +383,3 @@ - if ($action == 'delete') { - $numberofmochilds = count($object->getAllMoChilds()); - - if ($numberofmochilds > 0) { - $label = $langs->trans("DeleteMoChild", '('.strval($numberofmochilds).')'); - } else { - $label = $langs->trans("DeleteMoChild"); - } - - $formquestion = array( - array('type' => 'checkbox', 'name' => 'deletechilds', 'label' => $label, 'value' => 0), - array( - 'label' => $langs->trans('MoCancelConsumedAndProducedLines'), - 'name' => 'alsoCancelConsumedAndProducedLines', - 'type' => 'checkbox', - 'value' => !getDolGlobalString('MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1 - ) - ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', $formquestion, 0, 1); + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); @@ -516 +388,2 @@ - if ($action == 'deleteline') { + if ($action == 'deleteline') + { @@ -521 +394,2 @@ - if ($action == 'validate') { + if ($action == 'validate') + { @@ -526 +400 @@ - $numref = $object->getNextNumRef($object->product); + $numref = $object->getNextNumRef($object->fk_product); @@ -532 +406 @@ - /*if (isModEnabled('notification')) + /*if (! empty($conf->notification->enabled)) @@ -541 +415,2 @@ - if (isModEnabled('mrp')) { + if (!empty($conf->mrp->enabled)) + { @@ -546,3 +421 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -559,13 +431,0 @@ - // Confirmation to cancel - if ($action == 'cancel') { - $formquestion = array( - array( - 'label' => $langs->trans('MoCancelConsumedAndProducedLines'), - 'name' => 'alsoCancelConsumedAndProducedLines', - 'type' => 'checkbox', - 'value' => 0 - ), - ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CancelMo'), $langs->trans('ConfirmCancelMo'), 'confirm_cancel', $formquestion, 0, 1); - } - @@ -582,5 +442,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -602,6 +459,2 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= $langs->trans('ThirdParty').' '; + $morehtmlref .= ': '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -609,21 +462,28 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if ($permissiontoadd) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ' : '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } @@ -641,9 +500,0 @@ - - //Mo Parent - $mo_parent = $object->getMoParent(); - if (is_object($mo_parent)) { - print ''; - print '' . $langs->trans('ParentMo') . ''; - print '' .$mo_parent->getNomUrl(1).''; - print ''; - } @@ -666 +517 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -673,2 +524,3 @@ - if (!empty($object->table_element_line)) { - // Show object lines + if (!empty($object->table_element_line)) + { + // Show object lines @@ -678 +530 @@ - print '
+ print ' @@ -682 +533,0 @@ - @@ -686,58 +537,57 @@ - /*if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - }*/ - - if (!empty($object->lines)) { - print '
'; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans("Summary").'
'.$langs->trans("ProductsToConsume").''; - 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("ProductsToProduce").''; - 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 "
\n"; + /*if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + }*/ + + if (!empty($object->lines)) + { + print '
'; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Summary").'
'.$langs->trans("ProductsToConsume").''; + 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("ProductsToProduce").''; + 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 "\n"; @@ -750,73 +600,85 @@ - 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)) { - // Send - //if (empty($user->socid)) { - // print '' . $langs->trans('SendMail') . ''."\n"; - //} - - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) { - if ($permissiontoadd) { - // TODO Add test that production has not started - print ''.$langs->trans("SetToDraft").''; - } - } - - // Modify - if ($object->status == $object::STATUS_DRAFT) { - if ($permissiontoadd) { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } - } - - // Validate - if ($object->status == $object::STATUS_DRAFT) { - if ($permissiontoadd) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print ''.$langs->trans("Validate").''; - } else { - $langs->load("errors"); - print ''.$langs->trans("Validate").''; - } - } - } - - // Clone - if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=mo', 'clone', $permissiontoadd); - } - - // Cancel - Reopen - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { - $arrayproduced = $object->fetchLinesLinked('produced', 0); - $nbProduced = 0; - foreach ($arrayproduced as $lineproduced) { - $nbProduced += $lineproduced['qty']; - } - if ($nbProduced > 0) { // If production has started, we can close it - print ''.$langs->trans("Close").''."\n"; - } else { - print 'transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").''."\n"; - } - - print ''.$langs->trans("Cancel").''."\n"; - } - - if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) { - print ''.$langs->trans("ReOpen").''."\n"; - } - } - - // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); - } - print '
'."\n"; + 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)) + { + // Send + //if (empty($user->socid)) { + // print '' . $langs->trans('SendMail') . ''."\n"; + //} + + // Back to draft + if ($object->status == $object::STATUS_VALIDATED) + { + if ($permissiontoadd) + { + // TODO Add test that production has not started + print ''.$langs->trans("SetToDraft").''; + } + } + + // Modify + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + } + + // Validate + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) + { + print ''.$langs->trans("Validate").''; + } + else + { + $langs->load("errors"); + print ''.$langs->trans("Validate").''; + } + } + } + + // Clone + if ($permissiontoadd) + { + print ''.$langs->trans("ToClone").''; + } + + // Cancel - Reopen + if ($permissiontoadd) + { + if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) + { + // TODO If production is already > 1, show only close, else show cancel + print ''.$langs->trans("Close").''."\n"; + + print ''.$langs->trans("Cancel").''."\n"; + } + + if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) + { + print ''.$langs->trans("ReOpen").''."\n"; + } + } + + // Delete (need delete permission, or if draft, just need create/modify permission) + if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; @@ -831,30 +693,33 @@ - if ($action != 'presend') { - print '
'; - print ''; // ancre - - // Documents - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->mrp->dir_output.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content - $delallowed = $user->hasRight("mrp", "creer"); // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false); - - - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/mrp/mo_agenda.php?id='.$object->id); - - // 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, $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); - - print '
'; + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->mrp->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); + $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, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; @@ -864,3 +729 @@ - if (GETPOST('modelselected')) { - $action = 'presend'; - } + if (GETPOST('modelselected')) $action = 'presend'; --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_document.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_document.php @@ -15 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -47,2 +47,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -50,3 +50 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -56,6 +54,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; @@ -76,3 +70,2 @@ -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mrp->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object); -} +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->id); +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity ? $object->entity : $conf->entity]."/mo/".dol_sanitizeFileName($object->ref); @@ -86,2 +78,0 @@ -$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php - @@ -93 +84 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -108 +99,2 @@ -if ($object->id) { +if ($object->id) +{ @@ -114 +106,2 @@ - print dol_get_fiche_head($head, 'document', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'document', $langs->trans("MO"), -1, $object->picto); + @@ -117 +110 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -119 +112,2 @@ - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { @@ -132,6 +126 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -139 +128,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -141,7 +131,15 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); @@ -149 +146,0 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); @@ -154,4 +151,3 @@ - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; @@ -165 +161 @@ - print '
'; + print '
'; @@ -167 +163 @@ - print '
'; + print '
'; @@ -180 +176 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -183 +179 @@ - $permissiontoadd = $user->rights->mrp->write; + $permission = $user->rights->mrp->write; @@ -188 +184 @@ - $relativepathwithnofile = dol_sanitizeFileName($object->ref).'/'; + $relativepathwithnofile = 'mo/'.dol_sanitizeFileName($object->ref).'/'; @@ -190,2 +186,4 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_list.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_list.php @@ -15 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -23,0 +24,19 @@ +//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('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//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) +//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("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + @@ -30,2 +48,0 @@ -require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -42 +59 @@ -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... @@ -51 +67,0 @@ -$mode = GETPOST('mode', 'alpha'); @@ -56,3 +72,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -60,4 +76 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -82,6 +95,13 @@ -if (!$sortfield) { - $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition. -} -if (!$sortorder) { - $sortorder = "ASC"; -} +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; + +// Security check +if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); +$socid = 0; +if ($user->socid > 0) // Protection if external user +{ + //$socid = $user->socid; + accessforbidden(); +} +//$result = restrictedArea($user, 'mrp', $id, ''); + @@ -90 +110 @@ -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = GETPOST('search_all', 'alphanohtml') ? trim(GETPOST('search_all', 'alphanohtml')) : trim(GETPOST('sall', 'alphanohtml')); @@ -92,8 +112,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); - $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -104,7 +119,6 @@ -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns +foreach ($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +} + +// Definition of fields for list @@ -112 +126,2 @@ -foreach ($object->fields as $key => $val) { +foreach ($object->fields as $key => $val) +{ @@ -114,21 +129 @@ - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } - - if ($key == 'fk_parent_line') { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible <= 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); @@ -137,2 +132,14 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (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( + 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + ); + } + } +} @@ -146,7 +152,0 @@ -// Security check -if ($user->socid > 0) { - // Protection if external user - accessforbidden(); -} -$result = restrictedArea($user, 'mrp'); - @@ -158,7 +158,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -168,5 +163,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -177,2 +171,4 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach ($object->fields as $key => $val) + { @@ -180,7 +175,0 @@ - if ($key == 'status') { - $search[$key] = -1; - } - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } @@ -188 +177 @@ - $toselect = array(); + $toselect = ''; @@ -192 +181,2 @@ - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { @@ -216,2 +205,0 @@ -$morejs = array(); -$morecss = array(); @@ -223 +211,4 @@ -$sql .= $object->getFieldList('t'); +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; +} @@ -226,3 +217 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ""); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); @@ -233 +222 @@ -$sql .= $hookmanager->resPrint; +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); @@ -235,3 +223,0 @@ - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -239,59 +225,14 @@ -if (isset($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)"; -} -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mrp_production as lineparent ON t.fk_parent_line = lineparent.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mrp_mo as moparent ON lineparent.fk_mo = moparent.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON t.fk_product = p.rowid"; -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -} else { - $sql .= " WHERE 1 = 1"; -} - -foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - if ($key == 'fk_parent_line' && $search[$key] != '') { - $sql .= natural_search('moparent.ref', $search[$key], 0); - continue; - } - - if ($key == 'status') { - $sql .= natural_search('t.status', $search[$key], 0); - continue; - } - - - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); - } - } else { - if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); - if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { - if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} +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 ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); @@ -307,3 +248,4 @@ -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql .= "t.".$key.", "; +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; @@ -312,4 +254,2 @@ -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.", " : ""); - } +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.', ' : ''); @@ -319 +259 @@ -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook @@ -323,0 +264,2 @@ +$sql .= $db->order($sortfield, $sortorder); + @@ -326,13 +268,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { @@ -342,16 +277,19 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) +{ + $num = $nbtotalofrecords; +} +else +{ + if ($limit) $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} @@ -360 +298,2 @@ -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) +{ @@ -371,2 +310,16 @@ -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); - +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; @@ -377,23 +330,8 @@ -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -402,4 +339,0 @@ -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; @@ -409,4 +343,4 @@ - //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), - //'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"), + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), @@ -414,6 +348,2 @@ -if ($permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -422,4 +352,2 @@ -print '
'."\n"; -if ($optioncss != '') { - print ''; -} +print ''; +if ($optioncss != '') print ''; @@ -431 +358,0 @@ -print ''; @@ -433,9 +360,4 @@ -print ''; - -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'mrp', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -447 +369 @@ -$trackid = 'mo'.$object->id; +$trackid = 'xxxx'.$object->id; @@ -450,4 +372,3 @@ -if ($search_all) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } +if ($search_all) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -464,7 +385,5 @@ -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (!empty($moreforfilter)) +{ @@ -477 +396 @@ -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -487,21 +406,9 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'fk_parent_line') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { @@ -509,4 +416,3 @@ - if ($key == 'fk_parent_line') { - print ''; - print ''; - continue; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + elseif (strpos($val['type'], 'integer:') === 0) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); @@ -514,14 +420 @@ - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; - } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - } + elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; @@ -539,6 +432,4 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; -} +print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print ''; @@ -546,3 +436,0 @@ - -$totalarray = array(); -$totalarray['nbfield'] = 0; @@ -554,25 +442,10 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'fk_parent_line') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - if ($key == "fk_product") { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'p.ref', '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - } else { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - } - $totalarray['nbfield']++; +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; @@ -588,4 +461 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -597,11 +467,8 @@ -if (isset($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 (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } - } -} - - -$bom = new BOM($db); -$product = new Product($db); +if (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 + } +} + @@ -612 +478,0 @@ -$savnbfield = $totalarray['nbfield']; @@ -614,3 +480,2 @@ -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { +while ($i < ($limit ? min($num, $limit) : $num)) +{ @@ -618,3 +483 @@ - if (empty($obj)) { - break; // Should not happen - } + if (empty($obj)) break; // Should not happen @@ -625,22 +488,25 @@ - //mode Kanban - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - print '
'; - } - $object->id = $obj->type_id; - - // TODO Use a cache on BOM - if ($obj->fk_bom > 0) { - $bom->fetch($obj->fk_bom); - } - if ($obj->fk_product > 0) { - $product->fetch($obj->fk_product); - } - - // Output Kanban - $selected = -1; - 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($object->id, $arrayofselected)) { - $selected = 1; + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) + { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + else print $object->showOutputField($val, $key, $object->$key, ''); + print ''; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) + { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $object->$key; @@ -649,96 +515,20 @@ - print $object->getKanbanView('', array('bom'=>($obj->fk_bom > 0 ? $bom : null), 'product'=>($obj->fk_product > 0 ? $product : null), 'selected' => $selected)); - if ($i == ($imaxinloop - 1)) { - print '
'; - print ''; - } - } else { - // Show here line of result - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - 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($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - } - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'fk_parent_line') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'fk_parent_line') { - $moparent = $object->getMoParent(); - if (is_object($moparent)) { - print $moparent->getNomUrl(1); - } - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - 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($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + 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($object->id, $arrayofselected)) $selected = 1; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''."\n"; + @@ -753 +543,2 @@ -if ($num == 0) { +if ($num == 0) +{ @@ -755,6 +546,2 @@ - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''.$langs->trans("NoRecordFound").''; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; @@ -775 +562,2 @@ -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ @@ -777,3 +565 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_movements.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_movements.php @@ -3 +2,0 @@ - * Copyright (C) 2022 Ferran Marcet @@ -16 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -20,3 +19,3 @@ - * \file mo_movements.php - * \ingroup mrp - * \brief Page to show stock movements of a MO + * \file mo_movements.php + * \ingroup mrp + * \brief Page to show tock movements of a MO @@ -23,0 +23,20 @@ + +//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 + @@ -26,0 +46 @@ + @@ -35 +54,0 @@ - @@ -43,13 +62,11 @@ -$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') : 'mostockmovement'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$massaction = GETPOST('massaction', 'aZ09'); -$lineid = GETPOST('lineid', 'int'); - -$msid = GETPOST('msid', 'int'); -$year = GETPOST("year", 'int'); +$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') : 'mostockmovement'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +$msid = GETPOST('msid', 'int'); +$year = GETPOST("year", 'int'); @@ -57 +73,0 @@ - @@ -69,7 +85,5 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -77,6 +91,2 @@ -if (!$sortfield) { - $sortfield = "m.datem"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; @@ -98,4 +108,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -104,3 +113 @@ -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; @@ -121,18 +128,17 @@ - 'm.rowid'=>array('label'=>"Ref", 'checked'=>1, 'position'=>1), - 'm.datem'=>array('label'=>"Date", 'checked'=>1, 'position'=>2), - 'p.ref'=>array('label'=>"ProductRef", 'checked'=>1, 'css'=>'maxwidth100', 'position'=>3), - 'p.label'=>array('label'=>"ProductLabel", 'checked'=>0, 'position'=>5), - 'm.batch'=>array('label'=>"BatchNumberShort", 'checked'=>1, 'position'=>8, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.eatby'=>array('label'=>"EatByDate", 'checked'=>0, 'position'=>9, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.sellby'=>array('label'=>"SellByDate", 'checked'=>0, 'position'=>10, 'enabled'=>(isModEnabled('productbatch'))), - 'e.ref'=>array('label'=>"Warehouse", 'checked'=>1, 'position'=>100, 'enabled'=>(!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author'=>array('label'=>"Author", 'checked'=>0, 'position'=>120), - 'm.inventorycode'=>array('label'=>"InventoryCodeShort", 'checked'=>1, 'position'=>130), - 'm.label'=>array('label'=>"MovementLabel", 'checked'=>1, 'position'=>140), - 'm.type_mouvement'=>array('label'=>"TypeMovement", 'checked'=>0, 'position'=>150), - 'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155), - 'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180), - 'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200), - 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210) - //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) + 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), + 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), + 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1), + 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), + 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), + 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), + 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), + 'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0), + 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), + 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'enabled'=>0, 'checked'=>0), + //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) @@ -140,6 +145,0 @@ -if (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - unset($arrayfields['pl.sellby']); -} -if (getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - unset($arrayfields['pl.eatby']); -} @@ -149 +148,0 @@ -// Permissions @@ -157,7 +155,0 @@ -$permissiontoupdatecost = $user->hasRight('bom', 'write'); // User who can define cost must have knowledge of pricing - -if ($permissiontoupdatecost) { - $arrayfields['m.price']['enabled'] = 1; -} - -$arrayofselected = array(); @@ -170,7 +162,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -180,3 +167 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -187 +172,2 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +{ @@ -201 +187 @@ - $toselect = array(); + $toselect = ''; @@ -205,43 +191,43 @@ -if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); - - if (empty($backtopage) || ($cancel && empty($id))) { - //var_dump($backurlforlist);exit; - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); - } - } - $triggermodname = 'MO_MODIFY'; // Name of trigger action code to execute when we modify record - - // Actions cancel, add, update, delete or clone - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - // Actions when linking object each other - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; - - // Actions when printing a doc from card - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - // Actions to send emails - $triggersendname = 'MO_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; - $trackid = 'mo'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - - // Action to move up and down lines of object - //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - - if ($action == 'confirm_reopen') { - $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN'); - } +if (empty($reshook)) +{ + $error = 0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $triggersendname = 'MO_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid = 'mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + if ($action == 'confirm_reopen') { + $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN'); + } @@ -260 +246 @@ -$productlot = new Productlot($db); +$productlot = new ProductLot($db); @@ -264,3 +250 @@ -$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag'; - -llxHeader('', $langs->trans('Mo'), $help_url); +llxHeader('', $langs->trans('Mo'), ''); @@ -269 +253,2 @@ -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ @@ -274,2 +259 @@ - - print dol_get_fiche_head($head, 'stockmovement', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'stockmovement', $langs->trans("MO"), -1, $object->picto); @@ -280,2 +264,3 @@ - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); @@ -284 +269,2 @@ - if ($action == 'deleteline') { + if ($action == 'deleteline') + { @@ -295 +281,2 @@ - if ($action == 'xxx') { + if ($action == 'xxx') + { @@ -297 +284 @@ - /* + /* @@ -300,8 +287,8 @@ - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); @@ -313,5 +300,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -333,6 +317 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -340,21 +319,28 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if ($permissiontoadd) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } @@ -388 +374 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -433,3 +419 @@ - foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -444,3 +428 @@ - if (!empty($extrafields->attributes[$objectlist->table_element]) && is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; - } + if (is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; @@ -451,3 +433 @@ - if ($msid > 0) { - $sql .= " AND m.rowid = ".((int) $msid); - } + if ($msid > 0) $sql .= " AND m.rowid = ".$msid; @@ -456,3 +436 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $sql .= " AND p.fk_product_type = 0"; - } + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; @@ -460,30 +438,10 @@ - if (!empty($search_ref)) { - $sql .= natural_search('m.rowid', $search_ref, 1); - } - if (!empty($search_movement)) { - $sql .= natural_search('m.label', $search_movement); - } - if (!empty($search_inventorycode)) { - $sql .= natural_search('m.inventorycode', $search_inventorycode); - } - if (!empty($search_product_ref)) { - $sql .= natural_search('p.ref', $search_product_ref); - } - if (!empty($search_product)) { - $sql .= natural_search('p.label', $search_product); - } - if ($search_warehouse != '' && $search_warehouse != '-1') { - $sql .= natural_search('e.rowid', $search_warehouse, 2); - } - if (!empty($search_user)) { - $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); - } - if (!empty($search_batch)) { - $sql .= natural_search('m.batch', $search_batch); - } - if ($search_qty != '') { - $sql .= natural_search('m.value', $search_qty, 1); - } - if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { - $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); - } + if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); + if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); + if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); + if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); + if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); + if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); + if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); + if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); + if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); + if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); @@ -499 +457,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -502 +461,2 @@ - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -509,6 +468,0 @@ - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - } - $num = $db->num_rows($resql); - @@ -516,33 +470,11 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($id > 0) { - $param .= '&id='.urlencode($id); - } - if ($search_movement) { - $param .= '&search_movement='.urlencode($search_movement); - } - if ($search_inventorycode) { - $param .= '&search_inventorycode='.urlencode($search_inventorycode); - } - if ($search_type_mouvement) { - $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); - } - if ($search_product_ref) { - $param .= '&search_product_ref='.urlencode($search_product_ref); - } - if ($search_product) { - $param .= '&search_product='.urlencode($search_product); - } - if ($search_batch) { - $param .= '&search_batch='.urlencode($search_batch); - } - if ($search_warehouse > 0) { - $param .= '&search_warehouse='.urlencode($search_warehouse); - } - if ($search_user) { - $param .= '&search_user='.urlencode($search_user); - } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if ($search_user) $param .= '&search_user='.urlencode($search_user); @@ -559,3 +491 @@ - if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); - } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -565,3 +495 @@ - if ($optioncss != '') { - print ''; - } + if ($optioncss != '') print ''; @@ -575,9 +503,4 @@ - if ($id > 0) { - print ''; - } - - if ($id > 0) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); - } else { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); - } + if ($id > 0) print ''; + + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); @@ -589,7 +512,5 @@ - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } - - if (!empty($moreforfilter)) { + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { @@ -609 +530,2 @@ - if (!empty($arrayfields['m.rowid']['checked'])) { + if (!empty($arrayfields['m.rowid']['checked'])) + { @@ -615 +537,2 @@ - if (!empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) + { @@ -618,3 +541 @@ - if (!isModEnabled('productbatch')) { - print ' '; - } + if (empty($conf->productbatch->enabled)) print ' '; @@ -627 +548,2 @@ - if (!empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) + { @@ -630,4 +552,5 @@ - print ''; - print ''; - } - if (!empty($arrayfields['p.label']['checked'])) { + print ''; + print ''; + } + if (!empty($arrayfields['p.label']['checked'])) + { @@ -636 +559 @@ - print ''; + print ''; @@ -640 +563,2 @@ - if (!empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) + { @@ -643,5 +567,7 @@ - if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; - print ''; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { + if (!empty($arrayfields['pl.eatby']['checked'])) + { + print ''; + print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) + { @@ -652 +578,2 @@ - if (!empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) + { @@ -658 +585,2 @@ - if (!empty($arrayfields['m.fk_user_author']['checked'])) { + if (!empty($arrayfields['m.fk_user_author']['checked'])) + { @@ -664 +592,2 @@ - if (!empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) + { @@ -670 +599,2 @@ - if (!empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) + { @@ -676 +606,2 @@ - if (!empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) + { @@ -681 +612 @@ - print ''; + print ''; @@ -692 +623,2 @@ - if (!empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) + { @@ -698,7 +630,2 @@ - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print ''; - print '  '; - print ''; - } - if (!empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) + { @@ -710 +637,2 @@ - if (!empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) + { @@ -726 +654,2 @@ - if (!empty($arrayfields['m.datec']['checked'])) { + if (!empty($arrayfields['m.datec']['checked'])) + { @@ -731 +660,2 @@ - if (!empty($arrayfields['m.tms']['checked'])) { + if (!empty($arrayfields['m.tms']['checked'])) + { @@ -742,3 +671,0 @@ - $totalarray = array(); - $totalarray['nbfield'] = 0; - @@ -746 +673 @@ - if (!empty($arrayfields['m.rowid']['checked'])) { + if (!empty($arrayfields['m.rowid']['checked'])) @@ -748,3 +675 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) @@ -752,3 +677 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) @@ -756,3 +679 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) @@ -760,3 +681 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) @@ -764,3 +683 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['pl.eatby']['checked'])) { + if (!empty($arrayfields['pl.eatby']['checked'])) @@ -768,3 +685 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { + if (!empty($arrayfields['pl.sellby']['checked'])) @@ -772,2 +686,0 @@ - $totalarray['nbfield']++; - } @@ -777,3 +690,2 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.fk_user_author']['checked'])) { + } + if (!empty($arrayfields['m.fk_user_author']['checked'])) @@ -781,3 +693 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) @@ -785,3 +695 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) @@ -789,3 +697 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) @@ -793,3 +699 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) @@ -797,7 +701 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) @@ -805,3 +703 @@ - $totalarray['nbfield']++; - } - if (!empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) @@ -809,2 +704,0 @@ - $totalarray['nbfield']++; - } @@ -821 +714,0 @@ - $totalarray['nbfield']++; @@ -825 +717,0 @@ - $totalarray['nbfield']++; @@ -828 +719,0 @@ - $totalarray['nbfield']++; @@ -830,0 +722,6 @@ + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + $num = $db->num_rows($resql); + @@ -832,5 +729 @@ - $savnbfield = $totalarray['nbfield']; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { + while ($i < ($limit ? min($num, $limit) : $num)) { @@ -838,18 +730,0 @@ - - // Multilangs - if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled - // TODO Use a cache here - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $objp->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; - $sql .= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $objp->produit = $objtp->label; - } - } - } @@ -890 +765 @@ - print ''.dol_escape_htmltag($objp->mid).''; + print ''.$objp->mid.''; @@ -904 +779,7 @@ - print ''; + print ''; + /* + * $productstatic->id=$objp->rowid; + * $productstatic->ref=$objp->produit; + * $productstatic->type=$objp->type; + * print $productstatic->getNomUrl(1,'',16); + */ @@ -910 +791 @@ - if ($productlot->id > 0) { + if ($productlot->id > 0) @@ -912,3 +793,2 @@ - } else { - print dol_escape_htmltag($productlot->batch); // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. - } + else + print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. @@ -935 +814,0 @@ - // Inventory code @@ -937 +816,2 @@ - print ''; + // Inventory code + print ''; @@ -939 +819 @@ - print dol_escape_htmltag($objp->inventorycode); + print $objp->inventorycode; @@ -943 +822,0 @@ - // Label of movement @@ -945,3 +824,3 @@ - print ''.dol_escape_htmltag($objp->label).''; - } - // Type of movement + // Label of movement + print ''.$objp->label.''; + } @@ -948,0 +828 @@ + // Type of movement @@ -968,8 +847,0 @@ - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print ''; - if ($objp->fk_project != 0) { - print $movement->get_origin($objp->fk_project, 'project'); - } - print ''; - } @@ -979,5 +851,3 @@ - if ($objp->qty >0) { - print '+'.$objp->qty.''; - } else { - print ''.$objp->qty.''; - } + if ($objp->qt > 0) + print '+'; + print $objp->qty; @@ -989,3 +859,2 @@ - if ($objp->price != 0) { - print ''.price($objp->price).''; - } + if ($objp->price != 0) + print price($objp->price); @@ -996 +865,2 @@ - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { @@ -998 +868 @@ - if (in_array($objp->rowid, $arrayofselected)) { + if (in_array($obj->rowid, $arrayofselected)) @@ -1000,5 +870,4 @@ - } - print ''; - } - print ''; - if (!$i) { + print ''; + } + print ''; + if (!$i) @@ -1006 +874,0 @@ - } @@ -1011,4 +878,0 @@ - if (empty($num)) { - print ''.$langs->trans("NoRecordFound").''; - } - --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_note.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_note.php @@ -15 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -38 +38 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -53,3 +53 @@ -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mrp->multidir_output[empty($object->entity) ? $conf->entity : $object->entity]."/".$object->id; -} +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; @@ -63 +61,2 @@ -$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = 1; +//$permissionnote=$user->rights->mrp->creer; // Used by the include of actions_setnotes.inc.php @@ -71,8 +70 @@ - -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -92 +84,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -97 +90 @@ - print dol_get_fiche_head($head, 'note', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'note', $langs->trans("MO"), -1, $object->picto); @@ -108,6 +101 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -115 +103,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -117,7 +106,15 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); @@ -125 +121,0 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); @@ -130,4 +126,3 @@ - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= ' : '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; @@ -151 +146 @@ - print dol_get_fiche_end(); + dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/mrp/github_19.0.3_mo_production.php +++ /tmp/dsg/dolibarr/htdocs/mrp/client_mo_production.php @@ -2,3 +2 @@ -/* Copyright (C) 2019-2020 Laurent Destailleur - * Copyright (C) 2023 Christian Humpel - * Copyright (C) 2023 Vincent de Grandpré +/* Copyright (C) 2019 Laurent Destailleur @@ -17 +15 @@ - * along with this program. If not, see . + * along with this program. If not, see . @@ -21,3 +19,3 @@ - * \file mo_production.php - * \ingroup mrp - * \brief Page to make production on a MO + * \file mo_production.php + * \ingroup mrp + * \brief Page to make production on a MO @@ -24,0 +23,20 @@ + +//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 + @@ -28 +46 @@ -require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + @@ -32,2 +49,0 @@ -require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; -require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php'; @@ -40,2 +56,2 @@ -require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; - +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -44 +60 @@ -$langs->loadLangs(array("mrp", "stocks", "other", "product", "productbatch")); +$langs->loadLangs(array("mrp", "stocks", "other", "productbatch")); @@ -47,10 +63,8 @@ -$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') : 'mocard'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$fk_movement = GETPOST('fk_movement', 'int'); -$fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); +$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') : 'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); @@ -64,3 +78 @@ -$objectline = new MoLine($db); - -$hookmanager->initHooks(array('moproduction', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -74 +86 @@ -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -76,4 +88,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -82,3 +93 @@ -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; @@ -95 +103,0 @@ -// Permissions @@ -99,0 +108 @@ +$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -102,3 +110,0 @@ -$permissiontoupdatecost = $user->hasRight('bom', 'read'); // User who can define cost must have knowledge of pricing - -$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -113,143 +119,84 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); - - if (empty($backtopage) || ($cancel && empty($id))) { - //var_dump($backurlforlist);exit; - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); - } - } - $triggermodname = 'MO_MODIFY'; // Name of trigger action code to execute when we modify record - - if ($action == 'confirm_cancel' && $confirm == 'yes' && !empty($permissiontoadd)) { - $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); - if ($result > 0) { - header("Location: " . dol_buildpath('/mrp/mo_card.php?id=' . $object->id, 1)); - exit; - } else { - $action = ''; - setEventMessages($object->error, $object->errors, 'errors'); - } - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && !empty($permissiontodelete)) { - $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->delete($user, 0, $also_cancel_consumed_and_produced_lines); - if ($result > 0) { - header("Location: " . $backurlforlist); - exit; - } else { - $action = ''; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - // Actions cancel, add, update, delete or clone - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - // Actions when linking object each other - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; - - // Actions when printing a doc from card - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - // Actions to send emails - $triggersendname = 'MO_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; - $trackid = 'mo'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - - // Action to move up and down lines of object - //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - - if ($action == 'confirm_reopen' && $permissiontoadd) { - $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN'); - } - - if (($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton') && $permissiontoadd) - || ($action == 'confirm_addproduceline' && GETPOST('addproducelinebutton') && $permissiontoadd)) { - $moline = new MoLine($db); - - // Line to produce - $moline->fk_mo = $object->id; - $moline->qty = GETPOST('qtytoadd', 'int'); - $moline->fk_product = GETPOST('productidtoadd', 'int'); - if (GETPOST('addconsumelinebutton')) { - $moline->role = 'toconsume'; - } else { - $moline->role = 'toproduce'; - } - $moline->origin_type = 'free'; // free consume line - $moline->position = 0; - - // Is it a product or a service ? - if (!empty($moline->fk_product)) { - $tmpproduct = new Product($db); - $tmpproduct->fetch($moline->fk_product); - if ($tmpproduct->type == Product::TYPE_SERVICE) { - $moline->fk_default_workstation = $tmpproduct->fk_default_workstation; - } - $moline->disable_stock_change = ($tmpproduct->type == Product::TYPE_SERVICE ? 1 : 0); - if ($conf->global->PRODUCT_USE_UNITS) { - $moline->fk_unit = $tmpproduct->fk_unit; - } - } - // Extrafields - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_".$key]); - } - } - if (is_array($array_options) && count($array_options) > 0) { - $moline->array_options = $array_options; - } - - $resultline = $moline->create($user, false); // Never use triggers here - if ($resultline <= 0) { - $error++; - setEventMessages($moline->error, $moline->errors, 'errors'); - } - - $action = ''; - // Redirect to refresh the tab information - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - - if (in_array($action, array('confirm_consumeorproduce', 'confirm_consumeandproduceall')) && $permissiontoproduce) { - $stockmove = new MouvementStock($db); - - $labelmovement = GETPOST('inventorylabel', 'alphanohtml'); - $codemovement = GETPOST('inventorycode', 'alphanohtml'); - - $db->begin(); - $pos = 0; - // Process line to consume - foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { - $tmpproduct = new Product($db); - $tmpproduct->fetch($line->fk_product); - - $i = 1; - while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) { - $qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i)); - - if ($qtytoprocess != 0) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error = 0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $triggersendname = 'MO_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid = 'mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + if ($action == 'confirm_reopen') { + $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN'); + } + + if ($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton')) { + $moline = new MoLine($db); + + // Line to produce + $moline->fk_mo = $object->id; + $moline->qty = GETPOST('qtytoadd', 'int'); ; + $moline->fk_product = GETPOST('productidtoadd', 'int'); + $moline->role = 'toconsume'; + $moline->position = 0; + + $resultline = $moline->create($user, false); // Never use triggers here + if ($resultline <= 0) { + $error++; + setEventMessages($moline->error, $molines->errors, 'errors'); + } + + $action = ''; + } + + if (in_array($action, array('confirm_consumeorproduce', 'confirm_consumeandproduceall'))) { + $stockmove = new MouvementStock($db); + + $labelmovement = GETPOST('inventorylabel', 'alphanohtml'); + $codemovement = GETPOST('inventorycode', 'alphanohtml'); + + $db->begin(); + + // Process line to consume + foreach ($object->lines as $line) { + if ($line->role == 'toconsume') { + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + + $i = 1; + while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) { + $qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i)); + + if ($qtytoprocess != 0) { @@ -257,104 +204,94 @@ - if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (!(GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); - $error++; - } - if ($tmpproduct->status_batch && (!GETPOST('batch-'.$line->id.'-'.$i))) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); - $error++; - } - } - - $idstockmove = 0; - if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { - // Record stock movement - $id_product_batch = 0; - $stockmove->setOrigin($object->element, $object->id); - $stockmove->context['mrp_role'] = 'toconsume'; - - if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); - } else { - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess * -1, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); - } - if ($idstockmove < 0) { - $error++; - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } - } - - if (!$error) { - // Record consumption - $moline = new MoLine($db); - $moline->fk_mo = $object->id; - $moline->position = $pos; - $moline->fk_product = $line->fk_product; - $moline->fk_warehouse = GETPOST('idwarehouse-'.$line->id.'-'.$i); - $moline->qty = $qtytoprocess; - $moline->batch = GETPOST('batch-'.$line->id.'-'.$i); - $moline->role = 'consumed'; - $moline->fk_mrp_production = $line->id; - $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove; - $moline->fk_user_creat = $user->id; - - $resultmoline = $moline->create($user); - if ($resultmoline <= 0) { - $error++; - setEventMessages($moline->error, $moline->errors, 'errors'); - } - - $pos++; - } - } - - $i++; - } - } - } - - // Process line to produce - $pos = 0; - - foreach ($object->lines as $line) { - if ($line->role == 'toproduce') { - $tmpproduct = new Product($db); - $tmpproduct->fetch($line->fk_product); - - $i = 1; - while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { - $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); - $pricetoprocess = GETPOST('pricetoproduce-'.$line->id.'-'.$i) ? price2num(GETPOST('pricetoproduce-'.$line->id.'-'.$i)) : 0; - - if ($qtytoprocess != 0) { - // Check warehouse is set if we should have to - if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); - $error++; - } - if (isModEnabled('productbatch') && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); - $error++; - } - } - - $idstockmove = 0; - if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { - // Record stock movement - $id_product_batch = 0; - $stockmove->origin_type = $object->element; - $stockmove->origin_id = $object->id; - $stockmove->context['mrp_role'] = 'toproduce'; - - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); - if ($idstockmove < 0) { - $error++; - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } - } - - if (!$error) { + if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set + if (!(GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); + $error++; + } + if ($tmpproduct->status_batch && (!GETPOST('batch-'.$line->id.'-'.$i))) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); + $error++; + } + } + + $idstockmove = 0; + if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $object; + $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } + } + + if (!$error) { + $pos = 0; + // Record consumption + $moline = new MoLine($db); + $moline->fk_mo = $object->id; + $moline->position = $pos; + $moline->fk_product = $line->fk_product; + $moline->fk_warehouse = GETPOST('idwarehouse-'.$line->id.'-'.$i); + $moline->qty = $qtytoprocess; + $moline->batch = GETPOST('batch-'.$line->id.'-'.$i); + $moline->role = 'consumed'; + $moline->fk_mrp_production = $line->id; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = $user->id; + + $resultmoline = $moline->create($user); + if ($resultmoline <= 0) { + $error++; + setEventMessages($moline->error, $moline->errors, 'errors'); + } + + $pos++; + } + } + + $i++; + } + } + } + + // Process line to produce + foreach ($object->lines as $line) { + if ($line->role == 'toproduce') { + $tmpproduct = new Product($db); + $tmpproduct->fetch($line->fk_product); + + $i = 1; + while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { + $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); + + if ($qtytoprocess != 0) { + // Check warehouse is set if we should have to + if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set + if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); + $error++; + } + if ($tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); + $error++; + } + } + + $idstockmove = 0; + if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $object; + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } + } + + if (!$error) { + $pos = 0; @@ -362,135 +299,116 @@ - $moline = new MoLine($db); - $moline->fk_mo = $object->id; - $moline->position = $pos; - $moline->fk_product = $line->fk_product; - $moline->fk_warehouse = GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i); - $moline->qty = $qtytoprocess; - $moline->batch = GETPOST('batchtoproduce-'.$line->id.'-'.$i); - $moline->role = 'produced'; - $moline->fk_mrp_production = $line->id; - $moline->fk_stock_movement = $idstockmove; - $moline->fk_user_creat = $user->id; - - $resultmoline = $moline->create($user); - if ($resultmoline <= 0) { - $error++; - setEventMessages($moline->error, $moline->errors, 'errors'); - } - - $pos++; - } - } - - $i++; - } - } - } - - if (!$error) { - $consumptioncomplete = true; - $productioncomplete = true; - - if (GETPOST('autoclose', 'int')) { - foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { - $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); - $alreadyconsumed = 0; - foreach ($arrayoflines as $line2) { - $alreadyconsumed += $line2['qty']; - } - - if ($alreadyconsumed < $line->qty) { - $consumptioncomplete = false; - } - } - if ($line->role == 'toproduce') { - $arrayoflines = $object->fetchLinesLinked('produced', $line->id); - $alreadyproduced = 0; - foreach ($arrayoflines as $line2) { - $alreadyproduced += $line2['qty']; - } - - if ($alreadyproduced < $line->qty) { - $productioncomplete = false; - } - } - } - } else { - $consumptioncomplete = false; - $productioncomplete = false; - } - - // Update status of MO - dol_syslog("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); - //var_dump("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); - if ($consumptioncomplete && $productioncomplete) { - $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - } else { - $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED'); - } - if ($result <= 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($error) { - $action = str_replace('confirm_', '', $action); - $db->rollback(); - } else { - $db->commit(); - - // Redirect to avoid to action done a second time if we make a back from browser - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - - // Action close produced - if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - if ($result >= 0) { - // Define output language - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, 0, 0, 0); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'confirm_editline' && $permissiontoadd) { - $moline = new MoLine($db); - $res = $moline->fetch(GETPOST('lineid', 'int')); - if ($result > 0) { - $extrafields->fetch_name_optionals_label($moline->element); - foreach ($extrafields->attributes[$moline->table_element]['label'] as $key => $label) { - $value = GETPOST('options_'.$key, 'alphanohtml'); - $moline->array_options["options_".$key] = $value; - } - $moline->qty = GETPOST('qty_lineProduce', 'int'); - $res = $moline->update($user); - if ($res < 0) { - setEventMessages($moline->error, $moline->errors, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } + $moline = new MoLine($db); + $moline->fk_mo = $object->id; + $moline->position = $pos; + $moline->fk_product = $line->fk_product; + $moline->fk_warehouse = GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i); + $moline->qty = $qtytoprocess; + $moline->batch = GETPOST('batchtoproduce-'.$line->id.'-'.$i); + $moline->role = 'produced'; + $moline->fk_mrp_production = $line->id; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = $user->id; + + $resultmoline = $moline->create($user); + if ($resultmoline <= 0) { + $error++; + setEventMessages($moline->error, $moline->errors, 'errors'); + } + + $pos++; + } + } + + $i++; + } + } + } + + if (!$error) { + $consumptioncomplete = true; + $productioncomplete = true; + + if (GETPOST('autoclose', 'int')) { + foreach ($object->lines as $line) { + if ($line->role == 'toconsume') { + $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); + $alreadyconsumed = 0; + foreach ($arrayoflines as $line2) { + $alreadyconsumed += $line2['qty']; + } + + if ($alreadyconsumed < $line->qty) { + $consumptioncomplete = false; + } + } + if ($line->role == 'toproduce') { + $arrayoflines = $object->fetchLinesLinked('produced', $line->id); + $alreadyproduced = 0; + foreach ($arrayoflines as $line2) { + $alreadyproduced += $line2['qty']; + } + + if ($alreadyproduced < $line->qty) { + $productioncomplete = false; + } + } + } + } + else { + $consumptioncomplete = false; + $productioncomplete = false; + } + + // Update status of MO + dol_syslog("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); + //var_dump("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); + if ($consumptioncomplete && $productioncomplete) { + $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); + } else { + $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED'); + } + if ($result <= 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($error) { + $action = str_replace('confirm_', '', $action); + $db->rollback(); + } else { + $db->commit(); + + // Redirect to avoid to action done a second time if we make a back from browser + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + + // Action close produced + if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) + { + $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, 0, 0, 0); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } @@ -510,7 +428,3 @@ -$tmpstockmovement = new MouvementStock($db); - -$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag'; -$morejs = array('/mrp/js/lib_dispatch.js.php'); -llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, $morejs); - -$newToken = newToken(); + +$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; +llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, array('/mrp/js/lib_dispatch.js.php')); @@ -519 +433,2 @@ -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ @@ -523,5 +437,0 @@ - if (getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $object->fk_warehouse > 0) { - $tmpwarehouse->fetch($object->fk_warehouse); - $fk_default_warehouse = $object->fk_warehouse; - } - @@ -529,2 +439 @@ - - print dol_get_fiche_head($head, 'production', $langs->trans("ManufacturingOrder"), -1, $object->picto); + dol_fiche_head($head, 'production', $langs->trans("MO"), -1, $object->picto); @@ -535,10 +444,3 @@ - if ($action == 'delete') { - $formquestion = array( - array( - 'label' => $langs->trans('MoCancelConsumedAndProducedLines'), - 'name' => 'alsoCancelConsumedAndProducedLines', - 'type' => 'checkbox', - 'value' => 0 - ), - ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', $formquestion, 0, 1); + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); @@ -547,2 +449,3 @@ - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&fk_movement='.$fk_movement, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); @@ -558 +461,2 @@ - if ($action == 'validate') { + if ($action == 'validate') + { @@ -563 +467 @@ - $numref = $object->getNextNumRef($object->product); + $numref = $object->getNextNumRef($object->fk_product); @@ -569 +473 @@ - /*if (isModEnabled('notification')) + /*if (! empty($conf->notification->enabled)) @@ -578 +482,2 @@ - if (isModEnabled('mrp')) { + if (!empty($conf->mrp->enabled)) + { @@ -583,3 +488 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -596,13 +498,0 @@ - // Confirmation to cancel - if ($action == 'cancel') { - $formquestion = array( - array( - 'label' => $langs->trans('MoCancelConsumedAndProducedLines'), - 'name' => 'alsoCancelConsumedAndProducedLines', - 'type' => 'checkbox', - 'value' => !getDolGlobalString('MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1 - ), - ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CancelMo'), $langs->trans('ConfirmCancelMo'), 'confirm_cancel', $formquestion, 0, 1); - } - @@ -612,5 +502,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -622 +509 @@ - // MO file + // Object card @@ -624 +511 @@ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; @@ -627 +513,0 @@ - @@ -631,3 +517 @@ - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); - */ - + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ @@ -635,7 +519 @@ - if (is_object($object->thirdparty)) { - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } - + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); @@ -643,21 +521,28 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - if (is_object($object->thirdparty)) { - $morehtmlref .= '
'; - } - if ($permissiontoadd) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } @@ -691,4 +576,5 @@ - print dol_get_fiche_end(); - - - if (!in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + dol_fiche_end(); + + + if (!in_array($action, array('consumeorproduce', 'consumeandproduceall'))) + { @@ -702,5 +588,10 @@ - if ($object->status == $object::STATUS_DRAFT) { - if ($permissiontoadd) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print ''.$langs->trans("Validate").''; - } else { + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) + { + print ''.$langs->trans("Validate").''; + } + else + { @@ -716 +607 @@ - print ''.$langs->trans('ConsumeOrProduce').''; + print ''.$langs->trans('ConsumeOrProduce').''; @@ -727 +618 @@ - print ''.$langs->trans('ConsumeAndProduceAll').''; + print ''.$langs->trans('ConsumeAndProduceAll').''; @@ -736,14 +627,8 @@ - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { - $arrayproduced = $object->fetchLinesLinked('produced', 0); - $nbProduced = 0; - foreach ($arrayproduced as $lineproduced) { - $nbProduced += $lineproduced['qty']; - } - if ($nbProduced > 0) { // If production has started, we can close it - print ''.$langs->trans("Close").''."\n"; - } else { - print 'transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").''."\n"; - } - - print ''.$langs->trans("Cancel").''."\n"; + if ($permissiontoadd) + { + if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) + { + // TODO If production is already > 1, show only close, else show cancel + print ''.$langs->trans("Close").''."\n"; + + print ''.$langs->trans("Cancel").''."\n"; @@ -752,2 +637,3 @@ - if ($object->status == $object::STATUS_CANCELED) { - print ''.$langs->trans("ReOpen").''."\n"; + if ($object->status == $object::STATUS_CANCELED) + { + print ''.$langs->trans("Re-Open").''."\n"; @@ -758 +644 @@ - print ''.$langs->trans('ReOpen').''; + print ''.$langs->trans('ReOpen').''; @@ -769 +655,2 @@ - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline', 'addproduceline', 'editline'))) { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) + { @@ -779 +666,2 @@ - $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : dol_print_date(dol_now(), 'dayhourlog'); + //$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog'); + $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref); @@ -782,4 +670,3 @@ - print '
'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; - print ''.$langs->trans("InventoryCode").':   '; - print ''; - print $langs->trans("MovementLabel").':

'; + print ''.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; + print $langs->trans("MovementLabel").':   '; + print $langs->trans("InventoryCode").':

'; @@ -787 +674 @@ - print ''; + print ''; @@ -789 +676 @@ - print ''; + print ''; @@ -803,330 +690,93 @@ - if (!empty($object->table_element_line)) { - // Show object lines - $object->fetchLines(); - - $bomcost = 0; - if ($object->fk_bom > 0) { - $bom = new BOM($db); - $res = $bom->fetch($object->fk_bom); - if ($res > 0) { - $bom->calculateCosts(); - $bomcost = $bom->unit_cost; - } - } - - // Lines to consume - - print '
'; - print '
'; - print '
'; - - $url = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addconsumeline&token='.newToken(); - $permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED; - $parameters = array('morecss'=>'reposition'); - - $newcardbutton = ''; - if ($action != 'consumeorproduce' && $action != 'consumeandproduceall') { - $newcardbutton = dolGetButtonTitle($langs->trans('AddNewConsumeLines'), '', 'fa fa-plus-circle size15x', $url, '', $permissiontoaddaconsumeline, $parameters); - } - - print load_fiche_titre($langs->trans('Consumption'), $newcardbutton, '', 0, '', '', ''); - - print '
'; - print ''; - - print ''; - // Product - print ''; - // Qty - print ''; - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost && getDolGlobalString('MRP_SHOW_COST_FOR_CONSUMPTION')) { - print ''; - } - // Qty already consumed - print ''; - // Warehouse - print ''; - - if (isModEnabled('stock')) { - // Available - print ''; - } - // Lot - serial - if (isModEnabled('productbatch')) { - print ''; - } - // Action - if ($permissiontodelete) { - print ''; - } - - // Split - print ''; - - // SplitAll - print ''; - - // Edit Line - if ($object->status == Mo::STATUS_DRAFT) { - print ''; - } - - print ''; - - if ($action == 'addconsumeline') { - print ''."\n"; - print ''; - // Product - print ''; - // Qty - print ''; - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost && getDolGlobalString('MRP_SHOW_COST_FOR_CONSUMPTION')) { - print ''; - } - // Qty already consumed + Warehouse - print ''; - if (isModEnabled('stock')) { - print ''; - } - // Lot - serial - if (isModEnabled('productbatch')) { - print ''; - } - // Action - if ($permissiontodelete) { - print ''; - } - // Split - print ''; - // SplitAll - print ''; - // Edit Line - if ($object->status == Mo::STATUS_DRAFT) { - print ''; - } - print ''; - - // Extrafields Line - if (is_object($objectline)) { - $extrafields->fetch_name_optionals_label($object->table_element_line); - $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); - if (!empty($temps)) { - print ''; - } - } - } - - // Lines to consume - - $bomcostupdated = 0; // We will recalculate the unitary cost to produce a product using the real "products to consume into MO" - - if (!empty($object->lines)) { - $nblinetoconsume = 0; - foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { - $nblinetoconsume++; - } - } - - $nblinetoconsumecursor = 0; - foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { - $nblinetoconsumecursor++; - - $tmpproduct = new Product($db); - $tmpproduct->fetch($line->fk_product); - $linecost = price2num($tmpproduct->pmp, 'MT'); - - if ($object->qty > 0) { - // add free consume line cost to $bomcostupdated - $costprice = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); - if (empty($costprice)) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($db); - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { - $costprice = $productFournisseur->fourn_unitprice; - } else { - $costprice = 0; - } - } - $linecost = price2num(($line->qty * $costprice) / $object->qty, 'MT'); // price for line for all quantities - $bomcostupdated += price2num(($line->qty * $costprice) / $object->qty, 'MU'); // same but with full accuracy - } - - $bomcostupdated = price2num($bomcostupdated, 'MU'); - $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); - $alreadyconsumed = 0; - foreach ($arrayoflines as $line2) { - $alreadyconsumed += $line2['qty']; - } - - if ($action == 'editline' && $lineid == $line->id) { - $linecost = price2num($tmpproduct->pmp, 'MT'); - - $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); - $alreadyconsumed = 0; - if (is_array($arrayoflines) && !empty($arrayoflines)) { - foreach ($arrayoflines as $line2) { - $alreadyconsumed += $line2['qty']; - } - } - $suffix = '_' . $line->id; - print '' . "\n"; - // hidden fields for js function - print ''; - // Duration - Time spent - print ''; - print ''; - print ''; - - // Product - print ''; - - // Qty - print ''; - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Qty consumed - print ''; - // Entrepot - print ''; - // Stock - print ''; - - // Batch - /* - print ''; - */ - - // Action delete line - print ''; - - // Action delete line - if ($permissiontodelete) { - print ''; - } - print ''; - print ''; - - // Extrafields Line - if (!empty($extrafields)) { - $line->fetch_optionals(); - $temps = $line->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); - if (!empty($temps)) { - print ''; - } - } - } else { - $suffix = '_' . $line->id; - print '' . "\n"; - // hidden fields for js function - print ''; - print ''; - - print ''; - // Product - print ''; - // Qty - print ''; - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost && getDolGlobalString('MRP_SHOW_COST_FOR_CONSUMPTION')) { - print ''; - } - // Already consumed - print ''; - // Warehouse and/or workstation - print ''; - // Stock - if (isModEnabled('stock')) { - print ''; - } - // Lot - if (isModEnabled('productbatch')) { - print ''; - } - - // Split - print ''; - - // Split All - print ''; - - // Action Edit line - if ($object->status == Mo::STATUS_DRAFT) { - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=editline&token=' . newToken() . '&lineid=' . ((int) $line->id); - print ''; - } - - // Action delete line - if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=deleteline&token=' . newToken() . '&lineid=' . ((int) $line->id); - print ''; - } - - print ''; - // Extrafields Line - if (!empty($extrafields)) { - $line->fetch_optionals(); - $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); - if (!empty($temps)) { - print ''; - } - } - } - // Show detailed of already consumed with js code to collapse - foreach ($arrayoflines as $line2) { - print ''; - - // Date - print ''; - - // Already consumed - print ''; - - // Qty - print ''; - - // Cost price - if ($permissiontoupdatecost && getDolGlobalString('MRP_SHOW_COST_FOR_CONSUMPTION')) { - print ''; - } - - // Warehouse - print ''; - - // Stock - if (isModEnabled('stock')) { - print ''; - } - - // Lot Batch - if (isModEnabled('productbatch')) { - print ''; - } - - // Split - print ''; - - // Split All - print ''; - - // Action Edit line - if ($object->status == Mo::STATUS_DRAFT) { - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=editline&token=' . newToken() . '&lineid=' . ((int) $line2['rowid']); - print ''; - } - - // Action delete line - if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line2['rowid']).'&fk_movement='.((int) $line2['fk_stock_movement']); - print ''; - } - - print ''; - } - - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - $i = 1; - print ''."\n"; - $maxQty = 1; - print ''; - // Ref - print ''; - $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) { - $preselected = 0; - } - - $disable = ''; - if (getDolGlobalString('MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) { - $disable = 'disabled'; - } - - // input hidden with fk_product of line - print ''; - - // Qty - print ''; - - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - - // Cost - if ($permissiontoupdatecost && getDolGlobalString('MRP_SHOW_COST_FOR_CONSUMPTION')) { - print ''; - } - - // Already consumed - print ''; - - // Warehouse - print ''; - - // Stock - if (isModEnabled('stock')) { - print ''; - } - - // Lot / Batch - if (isModEnabled('productbatch')) { - print ''; - } - - // Split - $type = 'batch'; - print ''; - - // Split All - print ''; - - // Edit Line - if ($object->status == Mo::STATUS_DRAFT) { - print ''; - } - - // Action delete line - if ($permissiontodelete) { - print ''; - } - - print ''; - } - } - } - } - - print '
'.$langs->trans("Product").''.$langs->trans("Qty").'' . $langs->trans("Unit") . ''.$langs->trans("UnitCost").''.$form->textwithpicto($langs->trans("QtyAlreadyConsumedShort"), $langs->trans("QtyAlreadyConsumed")).''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print $langs->trans("Warehouse"); - if (isModEnabled('workstation')) { - print ' '.$langs->trans("or").' '.$langs->trans("Workstation"); - } - // Select warehouse to force it everywhere - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - $listwarehouses = $tmpwarehouse->list_array(1); - if (count($listwarehouses) > 1) { - print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans("ForceTo"), 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth200', 1); - } elseif (count($listwarehouses) == 1) { - print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth200', 1); - } - } - } - print '
'; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print $langs->trans("Stock"); - } - print ''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print $langs->trans("Batch"); - } - print '
'; - print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 1, array(), 0, '1', 0, 'maxwidth300'); - print ''; - print ''; - print ''; - print '
'; - print $temps; - print '
' . $tmpproduct->getNomUrl(1); - print '
' . $tmpproduct->label . ''; - print '
'; - print ''; - print ''; - print measuringUnitString($line->fk_unit, '', '', 1); - print ''; - print ' ' . price2num($alreadyconsumed, 'MS'); - print ''; - print ''; - if ($tmpproduct->isStockManaged()) { - if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { - print img_warning($langs->trans('StockTooLow')).' '; - } - print ''. $tmpproduct->stock_reel .' '; - } - print ''; - print ''; - print ''; - print ''; - print '
'; - print $temps; - print '
' . $tmpproduct->getNomUrl(1); - print '
' . $tmpproduct->label . '
'; - print '
'; - $help = ''; - $picto = 'help'; - if ($line->qty_frozen) { - $help = ($help ? '
' : '') . '' . $langs->trans("QuantityFrozen") . ': ' . yn(1) . ' (' . $langs->trans("QuantityConsumedInvariable") . ')'; - print $form->textwithpicto('', $help, -1, 'lock') . ' '; - } - if ($line->disable_stock_change) { - $help = ($help ? '
' : '') . '' . $langs->trans("DisableStockChange") . ': ' . yn(1) . ' (' . (($tmpproduct->type == Product::TYPE_SERVICE && !getDolGlobalString('STOCK_SUPPORTS_SERVICES')) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")) . ')'; - print $form->textwithpicto('', $help, -1, 'help') . ' '; - } - print price2num($line->qty, 'MS'); - print '
'; - print measuringUnitString($line->fk_unit, '', '', 1); - print ''; - print price($linecost); - print ''; - if ($alreadyconsumed) { - print ''; - if (empty($conf->use_javascript_ajax)) { - print 'id . '">'; - } - print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce' . $line->id . '"'); - if (empty($conf->use_javascript_ajax)) { - print ''; - } - } else { - if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line - print ''; - } - } - print ' ' . price2num($alreadyconsumed, 'MS'); - print ''; - if (getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) { - print img_picto('', $tmpwarehouse->picto) . " " . $tmpwarehouse->label; - } - if (isModEnabled('workstation') && $line->fk_default_workstation > 0) { - $tmpworkstation = new Workstation($db); - $tmpworkstation->fetch($line->fk_default_workstation); - print $tmpworkstation->getNomUrl(1); - } - print ''; - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES') && $tmpproduct->type != Product::TYPE_SERVICE) { - if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { - print img_warning($langs->trans('StockTooLow')) . ' '; - } - if (!getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) { - print price2num($tmpproduct->stock_reel, 'MS'); // Available - } else { - // Print only the stock in the selected warehouse - $tmpproduct->load_stock(); - $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id]; - if (!empty($wh_stock)) { - print price2num($wh_stock->real, 'MS'); - } else { - print "0"; - } - } - } - print ''; - print ''; - print img_picto($langs->trans('TooltipEditAndRevertStockMovement'), 'edit'); - print ''; - print ''; - print ''; - print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete'); - print ''; - print '
'; - print $temps; - print '
'; - $tmpstockmovement->id = $line2['fk_stock_movement']; - print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; - print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); - print ''.$line2['qty'].''; - if ($line2['fk_warehouse'] > 0) { - $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) { - print $tmpwarehouse->getNomUrl(1); - } - } - print ''; - if ($line2['batch'] != '') { - $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); - print $tmpbatch->getNomUrl(1); - } - print ''; - print ''; - print img_picto($langs->trans('TooltipEditAndRevertStockMovement'), 'edit'); - print ''; - print ''; - print ''; - print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete'); - print ''; - print '
'.$langs->trans("ToConsume").''; - if ($tmpproduct->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - if (empty($line->disable_stock_change)) { - $preselected = (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i) ? GETPOST('idwarehouse-'.$line->id.'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse : 'ifone')); - print $formproduct->selectWarehouses($preselected, 'idwarehouse-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); - } else { - print ''.$langs->trans("DisableStockChange").''; - } - } else { - print ''.$langs->trans("NoStockChangeOnServices").''; - } - print ''; - if ($tmpproduct->status_batch) { - $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); - print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); - } - print ''; - print ' '.img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).', \''.dol_escape_js($type).'\', \'qtymissingconsume\')"'); - print ''; - if (($action == 'consumeorproduce' || $action == 'consumeandproduceall') && $tmpproduct->status_batch == 2) { - print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.', \'batch\', \'allmissingconsume\')"'); - } - print '
'; + print ''; + if (empty($conf->use_javascript_ajax)) print 'id.'">'; + print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); + if (empty($conf->use_javascript_ajax)) print ''; + } else { + if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line + print ''; + } + } + print ' '.$alreadyconsumed; + print ''; + print ''; // Warehouse + print ''; + if ($conf->productbatch->enabled) { + print ''; // Lot + } + print ''; + + // Show detailed of already consumed with js code to collapse + foreach ($arrayoflines as $line2) { + print ''; + print ''; + print dol_print_date($line2['date'], 'dayhour'); + print ''; + print ''; + print ''.$line2['qty'].''; + print ''; + if ($line2['fk_warehouse'] > 0) { + $result = $tmpwarehouse->fetch($line2['fk_warehouse']); + if ($result > 0) print $tmpwarehouse->getNomUrl(1); + } + print ''; + // Lot Batch + print ''; + if ($line2['batch'] != '') { + $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); + print $tmpbatch->getNomUrl(1); + } + print ''; + print ''; + } + + if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + $i = 1; + print ''."\n"; + print ''; + print ''.$langs->trans("ToConsume").''; + $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); + if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; + print ''; + print ''; + print ''; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + if (empty($line->disable_stock_change)) { + $preselected = (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i) ? GETPOST('idwarehouse-'.$line->id.'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse : 'ifone')); + print $formproduct->selectWarehouses($preselected, 'idwarehouse-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth300'); + } else { + print ''.$langs->trans("DisableStockChange").''; + } + } else { + print ''.$langs->trans("NoStockChangeOnServices").''; + } + // Lot / Batch + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($tmpproduct->status_batch) { + $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); + print ''; + } + print ''; + } + print ''; + } + } + } + } + + print ''; + print '
'; + @@ -1399,209 +867,61 @@ - - // default warehouse processing - print ''; - - if (in_array($action, array('consumeorproduce', 'consumeandproduceall')) && - getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE')) { - print ''; - } - - - // Lines to produce - - print '
'; - print '
'; - print '
'; - - $nblinetoproduce = 0; - foreach ($object->lines as $line) { - if ($line->role == 'toproduce') { - $nblinetoproduce++; - } - } - - $newcardbutton = ''; - $url = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addproduceline&token='.newToken(); - $permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED; - $parameters = array('morecss'=>'reposition'); - if ($action != 'consumeorproduce' && $action != 'consumeandproduceall') { - if ($nblinetoproduce == 0 || $object->mrptype == 1) { - $newcardbutton = dolGetButtonTitle($langs->trans('AddNewProduceLines'), '', 'fa fa-plus-circle size15x', $url, '', $permissiontoaddaproductline, $parameters); - } - } - - print load_fiche_titre($langs->trans('Production'), $newcardbutton, '', 0, '', ''); - - print '
'; - print ''; - - print ''; - // Product - print ''; - // Qty - print ''; - /// Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost) { - if (empty($bomcostupdated)) { - print ''; - } else { - print ''; - } - } - // Already produced - print ''; - // Warehouse - print ''; - - // Lot - if (isModEnabled('productbatch')) { - print ''; - - // Split - print ''; - - // Split All - print ''; - } - - // Action delete - if ($permissiontodelete) { - print ''; - } - - print ''; - - if ($action == 'addproduceline') { - print ''."\n"; - print ''; - - // Product - print ''; - // Qty - print ''; - //Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost) { - print ''; - } - // Action (cost price + already produced) - print ''; - // Lot - serial - if (isModEnabled('productbatch')) { - print ''; - - // Split - print ''; - - // Split All - print ''; - } - // Action delete - if ($permissiontodelete) { - print ''; - } - print ''; - } - - if (!empty($object->lines)) { - $nblinetoproduce = 0; - foreach ($object->lines as $line) { - if ($line->role == 'toproduce') { - $nblinetoproduce++; - } - } - - $nblinetoproducecursor = 0; - foreach ($object->lines as $line) { - if ($line->role == 'toproduce') { - $i = 1; - - $nblinetoproducecursor++; - - $tmpproduct = new Product($db); - $tmpproduct->fetch($line->fk_product); - - $arrayoflines = $object->fetchLinesLinked('produced', $line->id); - $alreadyproduced = 0; - foreach ($arrayoflines as $line2) { - $alreadyproduced += $line2['qty']; - } - - $suffix = '_'.$line->id; - print ''."\n"; - // hidden fields for js function - print ''; - print ''; - - print ''; - // Product - print ''; - // Qty - print ''; - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost) { - // Defined $manufacturingcost - $manufacturingcost = 0; - $manufacturingcostsrc = ''; - if ($object->mrptype == 0) { // If MO is a "Manufacture" type (and not "Disassemble") - $manufacturingcost = $bomcostupdated; - $manufacturingcostsrc = $langs->trans("CalculatedFromProductsToConsume"); - if (empty($manufacturingcost)) { - $manufacturingcost = $bomcost; - $manufacturingcostsrc = $langs->trans("ValueFromBom"); - } - if (empty($manufacturingcost)) { - $manufacturingcost = price2num($tmpproduct->cost_price, 'MU'); - $manufacturingcostsrc = $langs->trans("CostPrice"); - } - if (empty($manufacturingcost)) { - $manufacturingcost = price2num($tmpproduct->pmp, 'MU'); - $manufacturingcostsrc = $langs->trans("PMPValue"); - } - } - - print ''; - } - // Already produced - print ''; - // Warehouse - print ''; - // Lot - if (isModEnabled('productbatch')) { - print ''; - - // Split - print ''; - - // Split All - print ''; - } - // Delete - if ($permissiontodelete) { - if ($line->origin_type == 'free') { - $href = $_SERVER["PHP_SELF"]; - $href .= '?id='.$object->id; - $href .= '&action=deleteline'; - $href .= '&lineid='.$line->id; - print ''; - } else { - print ''; - } - } - print ''; - - // Show detailed of already consumed with js code to collapse - foreach ($arrayoflines as $line2) { - print ''; - // Product - print ''; - // Qty - print ''; - // Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost price - if ($permissiontoupdatecost) { - print ''; - } - // Already produced - print ''; - // Warehouse - print ''; - // Lot - if (isModEnabled('productbatch')) { - print ''; - - // Split - print ''; - - // Split All - print ''; - } - // Action delete - if ($permissiontodelete) { - print ''; - } - print ''; - } - - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print ''."\n"; - $maxQty = 1; - print ''; - // Product - print ''; - $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { - $preselected = 0; - } - // Qty - print ''; - //Unit - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - // Cost - if ($permissiontoupdatecost) { - // Defined $manufacturingcost - $manufacturingcost = 0; - $manufacturingcostsrc = ''; - if ($object->mrptype == 0) { // If MO is a "Manufacture" type (and not "Disassemble") - $manufacturingcost = $bomcostupdated; - $manufacturingcostsrc = $langs->trans("CalculatedFromProductsToConsume"); - if (empty($manufacturingcost)) { - $manufacturingcost = $bomcost; - $manufacturingcostsrc = $langs->trans("ValueFromBom"); - } - if (empty($manufacturingcost)) { - $manufacturingcost = price2num($tmpproduct->cost_price, 'MU'); - $manufacturingcostsrc = $langs->trans("CostPrice"); - } - if (empty($manufacturingcost)) { - $manufacturingcost = price2num($tmpproduct->pmp, 'MU'); - $manufacturingcostsrc = $langs->trans("PMPValue"); - } - } - - if ($tmpproduct->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : ($manufacturingcost ? price($manufacturingcost) : '')); - print ''; - } else { - print ''; - } - } - // Already produced - print ''; - // Warehouse - print ''; - // Lot - if (isModEnabled('productbatch')) { - print ''; - // Batch number in same column than the stock movement picto - if ($tmpproduct->status_batch) { - $type = 'batch'; - print ''; - - print ''; - } else { - print ''; - - print ''; - } - } - - // Action delete - print ''; - - print ''; - } - } - } - } - - print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$form->textwithpicto($langs->trans("UnitCost"), $langs->trans("AmountUsedToUpdateWAP")).''.$form->textwithpicto($langs->trans("ManufacturingPrice"), $langs->trans("AmountUsedToUpdateWAP")).''.$form->textwithpicto($langs->trans("QtyAlreadyProducedShort"), $langs->trans("QtyAlreadyProduced")).''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print $langs->trans("Warehouse"); - } - print ''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { - print $langs->trans("Batch"); - } - print '
'; - print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 1, array(), 0, '1', 0, 'maxwidth300'); - print ''; - print ''; - print ''; - print '
'.$tmpproduct->getNomUrl(1); - print '
'.$tmpproduct->label.''; - print '
'.$line->qty.''.measuringUnitString($line->fk_unit, '', '', 1).''; - if ($manufacturingcost) { - print price($manufacturingcost); - } - print ''; - if ($alreadyproduced) { - print ''; - if (empty($conf->use_javascript_ajax)) { - print 'id.'">'; - } - print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) { - print ''; - } - } - print ' '.$alreadyproduced; - print ''; - print ''; - print ''; - print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), "delete"); - print ''; - print '
'; - $tmpstockmovement->id = $line2['fk_stock_movement']; - print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; - print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); - print ''.$line2['qty'].''; - if ($line2['fk_warehouse'] > 0) { - $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) { - print $tmpwarehouse->getNomUrl(1); - } - } - print ''; - if ($line2['batch'] != '') { - $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); - print $tmpbatch->getNomUrl(1); - } - print '
'.$langs->trans("ToProduce").''; - if ($tmpproduct->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $preselected = (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i) ? GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse : 'ifone')); - print $formproduct->selectWarehouses($preselected, 'idwarehousetoproduce-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); - } else { - print ''.$langs->trans("NoStockChangeOnServices").''; - } - print ''; - if ($tmpproduct->status_batch) { - $preselected = (GETPOSTISSET('batchtoproduce-'.$line->id.'-'.$i) ? GETPOST('batchtoproduce-'.$line->id.'-'.$i) : ''); - print ''; - } - print ''; - print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$line->id.', \''.$type.'\', \'qtymissing\')"'); - print ''; - if (($action == 'consumeorproduce' || $action == 'consumeandproduceall') && $tmpproduct->status_batch == 2) { - print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.', \'batch\', \'alltoproduce\')"'); - } // - print '
'; - print '
'; - - print '
'; - print '
'; + print ''; + if (empty($conf->use_javascript_ajax)) print 'id.'">'; + print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); + if (empty($conf->use_javascript_ajax)) print ''; + } + print ' '.$alreadyproduced; + print ''; + print ''; // Warehouse + print ''; + if ($conf->productbatch->enabled) { + print ''; // Lot + print ''; + } + print ''; + + // Show detailed of already consumed with js code to collapse + foreach ($arrayoflines as $line2) { + print ''; + print ''; + print dol_print_date($line2['date'], 'dayhour'); + print ''; + print ''; + print ''.$line2['qty'].''; + print ''; + if ($line2['fk_warehouse'] > 0) { + $result = $tmpwarehouse->fetch($line2['fk_warehouse']); + if ($result > 0) print $tmpwarehouse->getNomUrl(1); + } + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($line2['batch'] != '') { + $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); + print $tmpbatch->getNomUrl(1); + } + print ''; + print ''; + } + print ''; + } + + if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print ''; + print ''.$langs->trans("ToProduce").''; + $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); + if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; + print ''; + print ''; + print ''; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $preselected = (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i) ? GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse : 'ifone')); + print $formproduct->selectWarehouses($preselected, 'idwarehousetoproduce-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth300 csswarehouse_'.$line->id.'_'.$i); + } else { + print ''.$langs->trans("NoStockChangeOnServices").''; + } + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($tmpproduct->status_batch) { + $preselected = (GETPOSTISSET('batchtoproduce-'.$line->id.'-'.$i) ? GETPOST('batchtoproduce-'.$line->id.'-'.$i) : ''); + print ''; + } + print ''; + print ''; + if ($tmpproduct->status_batch) { + $type = 'batch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$line->id.', \''.$type.'\', \'qtymissing\')"'); + } + print ''; + } + print ''; + } + } + } + } + + print ''; + print '
'; + + print '
'; + print ''; @@ -1810 +1020,2 @@ - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) + { @@ -1812,113 +1023 @@ - } ?> - - - -