Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
97f62c68f2
@ -64,6 +64,10 @@ $sqls=array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement_facture where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement where rowid NOT IN (SELECT fk_paiement FROM ".MAIN_DB_PREFIX."paiement_facture)",
|
||||
),
|
||||
'supplier_payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn where fk_facturefourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn where rowid NOT IN (SELECT fk_paiementfourn FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn)",
|
||||
),
|
||||
'bank'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
@ -103,6 +107,7 @@ $sqls=array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
||||
),
|
||||
'supplier_invoice'=>array(
|
||||
'@supplier_payment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det WHERE fk_facture_fourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__'",
|
||||
),
|
||||
|
||||
@ -127,6 +127,18 @@ if (GETPOST('target') == 'local')
|
||||
{
|
||||
if (dol_is_file($xmlfile))
|
||||
{
|
||||
// If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before
|
||||
if (preg_match('/\.zip$/i', $xmlfile)) {
|
||||
dol_mkdir($conf->admin->dir_temp);
|
||||
$xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile);
|
||||
$result = dol_uncompress($xmlfile, $conf->admin->dir_temp);
|
||||
if (empty($result['error'])) {
|
||||
$xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew);
|
||||
} else {
|
||||
print $langs->trans('FailedToUncompressFile').': '.$xmlfile;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
$xml = simplexml_load_file($xmlfile);
|
||||
}
|
||||
else
|
||||
|
||||
@ -297,10 +297,7 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
|
||||
|
||||
|
||||
print '<td class="center">';
|
||||
|
||||
@ -34,7 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "members", "users"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
@ -244,10 +243,7 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
|
||||
|
||||
|
||||
print '<td class="center">';
|
||||
|
||||
@ -1461,6 +1461,7 @@ if ($id > 0)
|
||||
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td>';
|
||||
print '<input type="text" name="priority" value="'.($object->priority ? $object->priority : '').'" size="5">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Object linked
|
||||
if (!empty($object->fk_element) && !empty($object->elementtype))
|
||||
{
|
||||
|
||||
@ -1800,7 +1800,7 @@ class Propal extends CommonObject
|
||||
$this->newref = $num;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||
$sql .= " SET ref = '".$num."',";
|
||||
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
||||
$sql .= " fk_statut = ".self::STATUS_VALIDATED.", date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
|
||||
|
||||
|
||||
@ -4129,6 +4129,7 @@ class Form
|
||||
}
|
||||
|
||||
// Now add questions
|
||||
$moreonecolumn = '';
|
||||
$more .= '<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'."\n";
|
||||
foreach ($formquestion as $key => $input)
|
||||
{
|
||||
@ -4202,13 +4203,14 @@ class Form
|
||||
|
||||
elseif ($input['type'] == 'onecolumn')
|
||||
{
|
||||
$more .= '<div class="tagtr"><div class="tagtd">';
|
||||
$more .= $input['value'];
|
||||
$more .= '</div></div>'."\n";
|
||||
$moreonecolumn .= '<div class="margintoponly">';
|
||||
$moreonecolumn .= $input['value'];
|
||||
$moreonecolumn .= '</div>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$more .= '</div>'."\n";
|
||||
$more .= $moreonecolumn;
|
||||
}
|
||||
|
||||
// JQUI method dialog is broken with jmobile, we use standard HTML.
|
||||
|
||||
@ -1705,13 +1705,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
|
||||
// Date
|
||||
$out .= '<td class="center nowrap">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour');
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
|
||||
if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart'])
|
||||
{
|
||||
$tmpa = dol_getdate($histo[$key]['datestart'], true);
|
||||
$tmpb = dol_getdate($histo[$key]['dateend'], true);
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour');
|
||||
else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour');
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel');
|
||||
else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel');
|
||||
}
|
||||
$late = 0;
|
||||
if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1;
|
||||
|
||||
@ -1888,6 +1888,11 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
||||
$module='stock';
|
||||
$myobject='inventory';
|
||||
}
|
||||
elseif ($objecttype == 'mo') {
|
||||
$classpath = 'mrp/class';
|
||||
$module='mrp';
|
||||
$myobject='mo';
|
||||
}
|
||||
|
||||
// Generic case for $classfile and $classname
|
||||
$classfile = strtolower($myobject); $classname = ucfirst($myobject);
|
||||
|
||||
@ -1072,7 +1072,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
|
||||
if ($projectstatic->title)
|
||||
{
|
||||
print ' - ';
|
||||
print $projectstatic->title;
|
||||
print '<span class="secondary">'.$projectstatic->title.'</span>';
|
||||
}
|
||||
/*
|
||||
$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
@ -1451,7 +1451,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
if ($projectstatic->title)
|
||||
{
|
||||
print ' - ';
|
||||
print $projectstatic->title;
|
||||
print '<span class="secondary">'.$projectstatic->title.'</span>';
|
||||
}
|
||||
|
||||
/*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
|
||||
@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||
class InterfaceActionsBlockedLog extends DolibarrTriggers
|
||||
{
|
||||
public $family = 'system';
|
||||
public $description = "Triggers of this module add action for BlockedLog module.";
|
||||
public $description = "Triggers of this module add action for BlockedLog module (Module of unalterable logs).";
|
||||
|
||||
/**
|
||||
* Version of the trigger
|
||||
@ -45,7 +45,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
||||
public $picto = 'technic';
|
||||
|
||||
/**
|
||||
* Function called on Dolibarrr payment or invoice event.
|
||||
* Function called on Dolibarr payment or invoice event.
|
||||
*
|
||||
* @param string $action Event action code
|
||||
* @param Object $object Object
|
||||
|
||||
@ -46,7 +46,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
||||
|
||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||
$this->family = "ticket";
|
||||
$this->description = "Triggers of the module ticket";
|
||||
$this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties";
|
||||
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
|
||||
$this->picto = 'ticket';
|
||||
}
|
||||
|
||||
@ -537,7 +537,7 @@ CREATE TABLE llx_mrp_production(
|
||||
position integer NOT NULL DEFAULT 0,
|
||||
fk_product integer NOT NULL,
|
||||
fk_warehouse integer,
|
||||
qty integer NOT NULL DEFAULT 1,
|
||||
qty real NOT NULL DEFAULT 1,
|
||||
qty_frozen smallint DEFAULT 0,
|
||||
disable_stock_change smallint DEFAULT 0,
|
||||
batch varchar(30),
|
||||
@ -550,6 +550,7 @@ CREATE TABLE llx_mrp_production(
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14)
|
||||
) ENGINE=innodb;
|
||||
ALTER TABLE llx_mrp_production MODIFY COLUMN qty real NOT NULL DEFAULT 1;
|
||||
|
||||
ALTER TABLE llx_mrp_production ADD COLUMN qty_frozen smallint DEFAULT 0;
|
||||
ALTER TABLE llx_mrp_production ADD COLUMN disable_stock_change smallint DEFAULT 0;
|
||||
|
||||
@ -20,7 +20,7 @@ CREATE TABLE llx_mrp_production(
|
||||
position integer NOT NULL DEFAULT 0,
|
||||
fk_product integer NOT NULL,
|
||||
fk_warehouse integer,
|
||||
qty integer NOT NULL DEFAULT 1,
|
||||
qty real NOT NULL DEFAULT 1,
|
||||
qty_frozen smallint DEFAULT 0,
|
||||
disable_stock_change smallint DEFAULT 0,
|
||||
batch varchar(30),
|
||||
|
||||
@ -224,6 +224,7 @@ ErrorObjectMustHaveStatusActiveToBeDisabled=Objects must have status 'Active' to
|
||||
ErrorObjectMustHaveStatusDraftOrDisabledToBeActivated=Objects must have status 'Draft' or 'Disabled' to be enabled
|
||||
ErrorNoFieldWithAttributeShowoncombobox=No fields has property 'showoncombobox' into definition of object '%s'. No way to show the combolist.
|
||||
ErrorFieldRequiredForProduct=Field '%s' is required for product %s
|
||||
ProblemIsInSetupOfTerminal=Problem is in setup of terminal %s.
|
||||
# Warnings
|
||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.
|
||||
|
||||
@ -1013,3 +1013,4 @@ ContactDefault_supplier_proposal=Supplier Proposal
|
||||
ContactDefault_ticketsup=Ticket
|
||||
ContactAddedAutomatically=Contact added from contact thirdparty roles
|
||||
More=More
|
||||
ShowDetails=Show details
|
||||
|
||||
@ -60,6 +60,6 @@ TheProductXIsAlreadyTheProductToProduce=The product to add is already the produc
|
||||
ForAQuantityOf1=For a quantity to produce of 1
|
||||
ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order?
|
||||
ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements.
|
||||
ProductionForRefAndDate=Production %s - %s
|
||||
ProductionForRef=Production of %s
|
||||
AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached
|
||||
NoStockChangeOnServices=No stock change on services
|
||||
@ -467,6 +467,55 @@ class Mo extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of lines linked to current line for a defined role.
|
||||
*
|
||||
* @param string $role Get lines linked to current line with the selected role ('consumed', 'produced', ...)
|
||||
* @param int $lineid Id of production line to filter childs
|
||||
* @return array Array of lines
|
||||
*/
|
||||
public function fetchLinesLinked($role, $lineid = 0)
|
||||
{
|
||||
$resarray = array();
|
||||
$mostatic = new MoLine($this->db);
|
||||
|
||||
$sql = 'SELECT ';
|
||||
$sql .= $mostatic->getFieldList();
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$mostatic->table_element.' as t';
|
||||
$sql .= " WHERE t.role = '".$this->db->escape($role)."'";
|
||||
if ($lineid > 0) $sql .= ' AND t.fk_mrp_production = '.$lineid;
|
||||
else $sql .= 'AND t.fk_mo = '.$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i=0;
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$resarray[] = array(
|
||||
'rowid'=> $obj->rowid,
|
||||
'qty' => $obj->qty,
|
||||
'role' => $obj->role,
|
||||
'fk_product' => $obj->fk_product,
|
||||
'fk_warehouse' => $obj->fk_warehouse,
|
||||
'batch' => $obj->batch,
|
||||
'fk_stock_movement' => $obj->fk_stock_movement
|
||||
);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $resarray;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
var_dump($this->error);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
@ -999,8 +1048,8 @@ class Mo extends CommonObject
|
||||
$statusType = 'status'.$status;
|
||||
if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
|
||||
if ($status == self::STATUS_INPROGRESS) $statusType = 'status3';
|
||||
if ($status == self::STATUS_PRODUCED) $statusType = 'status5';
|
||||
if ($status == self::STATUS_CANCELED) $statusType = 'status6';
|
||||
if ($status == self::STATUS_PRODUCED) $statusType = 'status6';
|
||||
if ($status == self::STATUS_CANCELED) $statusType = 'status5';
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
@ -1282,7 +1331,7 @@ class MoLine extends CommonObjectLine
|
||||
'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
|
||||
'fk_product' =>array('type'=>'integer', 'label'=>'Fk product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
||||
'fk_warehouse' =>array('type'=>'integer', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
||||
'qty' =>array('type'=>'integer', 'label'=>'Qty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
|
||||
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
|
||||
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
|
||||
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
|
||||
'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
|
||||
@ -1458,25 +1507,6 @@ class MoLine extends CommonObjectLine
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of lines linked to current line for a defined role
|
||||
*
|
||||
* @param string $role Get lines linked to current line with the selected role ('consumed', 'produced', ...)
|
||||
* @return array Array of lines
|
||||
*/
|
||||
public function fetchLinesLinked($role)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$sql = 'SELECT rowid, qty ';
|
||||
$sql .= $this->getFieldList();
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
|
||||
else $sql .= ' WHERE 1 = 1';
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
|
||||
@ -242,7 +242,7 @@ if ($object->id > 0)
|
||||
$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);
|
||||
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -104,6 +104,7 @@ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->enti
|
||||
|
||||
$permissiontoproduce = $permissiontoadd;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -152,7 +153,11 @@ if (empty($reshook))
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
|
||||
if ($action == 'confirm_consumeandproduceall') {
|
||||
if ($action == 'confirm_reopen') {
|
||||
$result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN');
|
||||
}
|
||||
|
||||
if (in_array($action, array('confirm_consume', 'confirm_produce', 'confirm_consumeandproduceall'))) {
|
||||
$stockmove = new MouvementStock($db);
|
||||
|
||||
$labelmovement = GETPOST('inventorylabel', 'alphanohtml');
|
||||
@ -168,54 +173,59 @@ if (empty($reshook))
|
||||
|
||||
$i=1;
|
||||
while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
|
||||
// Check warehouse is set if we should have to
|
||||
if (GETPOST('idwarehouse-'.$line->id.'-'.$i)) {
|
||||
if (! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) {
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
$qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i));
|
||||
|
||||
$idstockmove = 0;
|
||||
if (! $error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) {
|
||||
// Record stock movement
|
||||
$id_product_batch = 0;
|
||||
$idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), GETPOST('qty-'.$line->id.'-'.$i), 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
||||
if ($idstockmove < 0) {
|
||||
$error++;
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
}
|
||||
}
|
||||
if ($qtytoprocess != 0) {
|
||||
// Check warehouse is set if we should have to
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
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 = GETPOST('qty-'.$line->id.'-'.$i);
|
||||
$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;
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
$resultmoline = $moline->create($user);
|
||||
if ($resultmoline <= 0) {
|
||||
$error++;
|
||||
setEventMessages($moline->error, $moline->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;
|
||||
|
||||
$pos++;
|
||||
}
|
||||
$resultmoline = $moline->create($user);
|
||||
if ($resultmoline <= 0) {
|
||||
$error++;
|
||||
setEventMessages($moline->error, $moline->errors, 'errors');
|
||||
}
|
||||
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -230,53 +240,58 @@ if (empty($reshook))
|
||||
|
||||
$i=1;
|
||||
while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) {
|
||||
// Check warehouse is set if we should have to
|
||||
if (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i)) {
|
||||
if (! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) {
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
$qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i));
|
||||
|
||||
$idstockmove = 0;
|
||||
if (! $error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) {
|
||||
// Record stock movement
|
||||
$id_product_batch = 0;
|
||||
$idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), GETPOST('qtytoproduce-'.$line->id.'-'.$i), 0, $labelmovement, dol_now(), '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
||||
if ($idstockmove < 0) {
|
||||
$error++;
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
}
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$pos = 0;
|
||||
// Record production
|
||||
$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 = GETPOST('qtytoproduce-'.$line->id.'-'.$i);
|
||||
$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;
|
||||
$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, dol_now(), '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
||||
if ($idstockmove < 0) {
|
||||
$error++;
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
$resultmoline = $moline->create($user);
|
||||
if ($resultmoline <= 0) {
|
||||
$error++;
|
||||
setEventMessages($moline->error, $moline->errors, 'errors');
|
||||
}
|
||||
if (! $error) {
|
||||
$pos = 0;
|
||||
// Record production
|
||||
$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;
|
||||
|
||||
$pos++;
|
||||
$resultmoline = $moline->create($user);
|
||||
if ($resultmoline <= 0) {
|
||||
$error++;
|
||||
setEventMessages($moline->error, $moline->errors, 'errors');
|
||||
}
|
||||
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -285,13 +300,47 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
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
|
||||
$qtyremaintoconsume = 0;
|
||||
$qtyremaintoproduce = 0;
|
||||
if ($qtyremaintoconsume == 0 && $qtyremaintoproduce == 0) {
|
||||
$result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED');
|
||||
} else {
|
||||
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++;
|
||||
@ -304,6 +353,10 @@ if (empty($reshook))
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -479,7 +532,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
|
||||
}
|
||||
} else {
|
||||
} elseif ($object->status == Mo::STATUS_DRAFT) {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Consume').'</a>';
|
||||
}
|
||||
|
||||
@ -490,7 +543,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
|
||||
}
|
||||
} else {
|
||||
} elseif ($object->status == Mo::STATUS_DRAFT) {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Produce').'</a>';
|
||||
}
|
||||
|
||||
@ -501,9 +554,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
|
||||
}
|
||||
} else {
|
||||
} elseif ($object->status == Mo::STATUS_DRAFT) {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
|
||||
}
|
||||
|
||||
// Reopen
|
||||
if ($object->status == Mo::STATUS_PRODUCED) {
|
||||
if ($permissiontoproduce) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen">'.$langs->trans('ReOpen').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ReOpen').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
@ -517,31 +579,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
if ($action == 'consume')
|
||||
{
|
||||
print $langs->trans("FeatureNotYetAvailable");
|
||||
}
|
||||
if ($action == 'produce')
|
||||
{
|
||||
print $langs->trans("FeatureNotYetAvailable");
|
||||
}
|
||||
if ($action == 'consumeandproduceall')
|
||||
{
|
||||
$defaultstockmovementlabel = GETPOST('inventorylabel', 'alphanohtml') ? GETPOST('inventorylabel', 'alphanohtml') : $langs->trans("ProductionForRefAndDate", $object->ref, dol_print_date(dol_now(), 'standard'));
|
||||
//$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog');
|
||||
$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref;
|
||||
$defaultstockmovementlabel = GETPOST('inventorylabel', 'alphanohtml') ? GETPOST('inventorylabel', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref);
|
||||
//$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);
|
||||
|
||||
print '<div class="center">';
|
||||
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></span>';
|
||||
print $langs->trans("MovementLabel").': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.'"> ';
|
||||
print $langs->trans("InventoryCode").': <input type="text" class="maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.'"><br><br>';
|
||||
print '<input type="checkbox" name="autoclose" value="1" checked="checked"> '.$langs->trans("AutoCloseMO").'<br>';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Confirm").'" name="confirm">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Cancel").'" name="cancel">';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
}
|
||||
print '<div class="center">';
|
||||
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></span>';
|
||||
print $langs->trans("MovementLabel").': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.'"> ';
|
||||
print $langs->trans("InventoryCode").': <input type="text" class="maxwidth200" name="inventorycode" value="'.$defaultstockmovementcode.'"><br><br>';
|
||||
print '<input type="checkbox" id="autoclose" name="autoclose" value="1"'.(GETPOSTISSET('inventorylabel') ? (GETPOST('autoclose') ? ' checked="checked"' : '') : ' checked="checked"').'> <label for="autoclose">'.$langs->trans("AutoCloseMO").'</label><br>';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Confirm").'" name="confirm">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Cancel").'" name="cancel">';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
@ -569,11 +620,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<td>'.$langs->trans("Qty").'</td>';
|
||||
print '<td>'.$langs->trans("QtyAlreadyConsumed").'</td>';
|
||||
print '<td>';
|
||||
if ($action == 'consumeandproduceall') print $langs->trans("Warehouse");
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) print $langs->trans("Warehouse");
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td>';
|
||||
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) print $langs->trans("Batch");
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
@ -585,10 +636,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$tmpproduct = new Product($db);
|
||||
$tmpproduct->fetch($line->fk_product);
|
||||
|
||||
$arrayoflines = $line->fetchLinesLinked('consumed');
|
||||
$arrayoflines = $object->fetchLinesLinked('consumed', $line->id);
|
||||
$alreadyconsumed = 0;
|
||||
foreach($arrayoflines as $line2) {
|
||||
$alreadyconsumed += $line2->qty;
|
||||
$alreadyconsumed += $line2['qty'];
|
||||
}
|
||||
|
||||
print '<tr>';
|
||||
@ -604,21 +655,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>'.$alreadyconsumed.'</td>';
|
||||
print '<td>';
|
||||
print '</td>'; // Warehouse
|
||||
print '<td>'; // Warehouse
|
||||
if ($alreadyconsumed) {
|
||||
print '<script>';
|
||||
print 'jQuery(document).ready(function() {
|
||||
jQuery("#expandtoproduce'.$line->id.'").click(function() {
|
||||
console.log("Expand mrp_production line '.$line->id.'");
|
||||
jQuery(".expanddetail'.$line->id.'").toggle();
|
||||
});
|
||||
});';
|
||||
print '</script>';
|
||||
if (empty($conf->use_javascript_ajax)) print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">';
|
||||
print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"');
|
||||
if (empty($conf->use_javascript_ajax)) print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td></td>'; // Lot
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
// Show detailed of already consumed with js code to collapse
|
||||
//$arrayoflines = $line->fetchLinesLinked('consumed');
|
||||
//$arrayoflines = $object->fetchLinesLinked('consumed', $line->id);
|
||||
|
||||
if ($action == 'consumeandproduceall') {
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) {
|
||||
$i = 1;
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ToConsume").'</td>';
|
||||
print '<td><input type="text" class="width50" name="qty-'.$line->id.'-'.$i.'" value="'.(GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)).'"></td>';
|
||||
$preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed));
|
||||
if ($action == 'produce') $preselected = 0;
|
||||
print '<td><input type="text" class="width50" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
|
||||
print '<td></td>';
|
||||
print '<td>';
|
||||
if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
|
||||
@ -681,11 +747,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<td>'.$langs->trans("Qty").'</td>';
|
||||
print '<td>'.$langs->trans("QtyAlreadyProduced").'</td>';
|
||||
print '<td>';
|
||||
if ($action == 'consumeandproduceall') print $langs->trans("Warehouse");
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) print $langs->trans("Warehouse");
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td>';
|
||||
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) print $langs->trans("Batch");
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
@ -697,31 +763,49 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$tmpproduct = new Product($db);
|
||||
$tmpproduct->fetch($line->fk_product);
|
||||
|
||||
$arrayoflines = $line->fetchLinesLinked('produced');
|
||||
$arrayoflines = $object->fetchLinesLinked('produced', $line->id);
|
||||
$alreadyproduced = 0;
|
||||
foreach($arrayoflines as $line2) {
|
||||
$alreadyproduced += $line2->qty;
|
||||
$alreadyproduced += $line2['qty'];
|
||||
}
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
|
||||
print '<td>'.$line->qty.'</td>';
|
||||
print '<td>'.$alreadyproduced.'</td>';
|
||||
print '<td></td>'; // Warehouse
|
||||
print '<td>'; // Warehouse
|
||||
if ($alreadyproduced) {
|
||||
print '<script>';
|
||||
print 'jQuery(document).ready(function() {
|
||||
jQuery("#expand'.$line->id.'").click(function() {
|
||||
console.log("Expand mrp_production line '.$line->id.'");
|
||||
jQuery(".expanddetail'.$line->id.'").toggle();
|
||||
});
|
||||
});';
|
||||
print '</script>';
|
||||
if (empty($conf->use_javascript_ajax)) print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">';
|
||||
print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expand'.$line->id.'"');
|
||||
if (empty($conf->use_javascript_ajax)) print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td></td>'; // Lot
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
if ($action == 'consumeandproduceall') {
|
||||
if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ToProduce").'</td>';
|
||||
print '<td><input type="text" class="width50" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.(GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)).'"></td>';
|
||||
$preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced));
|
||||
if ($action == 'consume') $preselected = 0;
|
||||
print '<td><input type="text" class="width50" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
|
||||
print '<td></td>';
|
||||
print '<td>';
|
||||
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);
|
||||
} else {
|
||||
print '<span class="opacitymedium">'.$langs->trans("NoStockChangeOnServices").'</span>';
|
||||
}
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
|
||||
@ -942,6 +942,10 @@ class MouvementStock extends CommonObject
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$origin = new Project($this->db);
|
||||
break;
|
||||
case 'mo':
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
|
||||
$origin = new Mo($this->db);
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($origintype)
|
||||
|
||||
@ -674,9 +674,9 @@ if ($resql)
|
||||
}
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
if ($id > 0) $param .= '&id='.$id;
|
||||
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);
|
||||
@ -684,10 +684,8 @@ if ($resql)
|
||||
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 (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined
|
||||
if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined
|
||||
if ($search_user) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($idproduct > 0) $param .= '&idproduct='.$idproduct;
|
||||
if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct);
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -752,6 +750,7 @@ if ($resql)
|
||||
}
|
||||
if (!empty($arrayfields['m.datem']['checked']))
|
||||
{
|
||||
// Date
|
||||
print '<td class="liste_titre nowraponall">';
|
||||
print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">';
|
||||
if (empty($conf->productbatch->enabled)) print ' ';
|
||||
@ -1008,7 +1007,7 @@ if ($resql)
|
||||
if (!empty($arrayfields['m.datem']['checked']))
|
||||
{
|
||||
// Date
|
||||
print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>';
|
||||
print '<td class="nowraponall">'.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').'</td>';
|
||||
}
|
||||
if (!empty($arrayfields['p.ref']['checked']))
|
||||
{
|
||||
|
||||
@ -693,7 +693,7 @@ if ($conf->use_javascript_ajax)
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
|
||||
print $langs->trans("Total");
|
||||
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
|
||||
print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
|
||||
print '</td>';
|
||||
|
||||
for ($idw = 0; $idw < 7; $idw++)
|
||||
@ -810,7 +810,7 @@ if (count($tasksarray) > 0)
|
||||
print '<tr class="liste_total">
|
||||
<td class="liste_total" colspan="'.($colspan+$addcolspan).'">';
|
||||
print $langs->trans("Total");
|
||||
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
|
||||
print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
|
||||
print '</td>';
|
||||
|
||||
for ($idw = 0; $idw < 7; $idw++)
|
||||
|
||||
@ -688,7 +688,7 @@ if ($resql) {
|
||||
if (empty($paiementsModes)) {
|
||||
$langs->load('errors');
|
||||
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
|
||||
setEventMessages($langs->trans("ProblemIsInSetupOfTerminal").' '.$_SESSION["takeposterminal"], null, 'errors');
|
||||
setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
|
||||
}
|
||||
if (count($maincategories) == 0) {
|
||||
setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
|
||||
|
||||
@ -2581,7 +2581,7 @@ else
|
||||
if ($conf->accounting->enabled)
|
||||
{
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield)
|
||||
{
|
||||
@ -2647,7 +2647,7 @@ else
|
||||
// Company / Contact
|
||||
if (!empty($conf->societe->enabled))
|
||||
{
|
||||
print '<tr><td width="25%">'.$langs->trans("LinkToCompanyContact").'</td>';
|
||||
print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
|
||||
print '<td>';
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
@ -2674,7 +2674,7 @@ else
|
||||
if (!empty($conf->adherent->enabled))
|
||||
{
|
||||
$langs->load("members");
|
||||
print '<tr><td width="25%">'.$langs->trans("LinkedToDolibarrMember").'</td>';
|
||||
print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
|
||||
print '<td>';
|
||||
if ($object->fk_member)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user