diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index bab853c35b2..3757a6ab766 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -968,8 +968,8 @@ if (empty($action) || $action == 'view') { journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); - // Test that setup is complete - $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL AND clos=0'; + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE entity = '.$conf->entity.' AND fk_accountancy_journal IS NULL AND clos=0'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 09837405f04..e0bde62b10e 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -388,46 +388,17 @@ print "\n"; print ''; -if (!empty($arrayfields['d.ref']['checked'])) -{ - print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['d.fk_type']['checked'])) -{ - print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['d.lastname']['checked'])) -{ - print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['d.firstname']['checked'])) -{ - print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['d.login']['checked'])) -{ - print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['t.libelle']['checked'])) -{ - print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); -} -if (!empty($arrayfields['d.bank']['checked'])) -{ - print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder); -} -if (!empty($arrayfields['c.dateadh']['checked'])) -{ - print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); -} -if (!empty($arrayfields['c.datef']['checked'])) -{ - print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); -} -if (!empty($arrayfields['d.amount']['checked'])) -{ - print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right '); -} +if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['d.fk_type']['checked'])) print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); +if (! empty($arrayfields['d.bank']['checked'])) print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder); +if (! empty($arrayfields['c.dateadh']['checked'])) print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); +if (! empty($arrayfields['c.datef']['checked'])) print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); +if (! empty($arrayfields['d.amount']['checked'])) print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right '); + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 76743258193..0adf7cd2a6a 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -576,8 +576,10 @@ class pdf_standard extends ModeleExpenseReport } $expensereporttypecode = $object->lines[$linenumber]->type_fees_code; - $expensereporttypecodetoshow = $outputlangs->trans($expensereporttypecode); - if ($expensereporttypecodetoshow == $expensereporttypecode) { + $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode)); + + + if ($expensereporttypecodetoshow == $expensereporttypecode) { $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); } //$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index b054df452d7..9a756ba3a79 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -66,3 +66,6 @@ AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume NoStockChangeOnServices=No stock change on services ProductQtyToConsumeByMO=Product quantity still to consume by open MO ProductQtyToProduceByMO=Product quentity still to produce by open MO +AddNewConsumeLines=Add new line to consume +ProductsToConsume=Products to consume +ProductsToProduce=Products to produce \ No newline at end of file diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 52c02b0f762..9e9b317196e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -607,66 +607,69 @@ class Mo extends CommonObject $this->db->begin(); // Insert lines in mrp_production table from BOM data - if (!$error && $this->fk_bom > 0) + if (!$error) { // TODO Check that production has not started. If yes, we stop here. + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'mrp_production WHERE fk_mo = '.$this->id; $this->db->query($sql); - include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; - $bom = new Bom($this->db); - $bom->fetch($this->fk_bom); - if ($bom->id > 0) - { - $moline = new MoLine($this->db); + $moline = new MoLine($this->db); - // Line to produce - $moline->fk_mo = $this->id; - $moline->qty = $this->qty; - $moline->fk_product = $this->fk_product; - $moline->role = 'toproduce'; - $moline->position = 1; + // Line to produce + $moline->fk_mo = $this->id; + $moline->qty = $this->qty; + $moline->fk_product = $this->fk_product; + $moline->role = 'toproduce'; + $moline->position = 1; - $resultline = $moline->create($user, false); // Never use triggers here - if ($resultline <= 0) { - $error++; - $this->error = $moline->error; - $this->errors = $moline->errors; - dol_print_error($this->db, $moline->error, $moline->errors); - } + $resultline = $moline->create($user, false); // Never use triggers here + if ($resultline <= 0) { + $error++; + $this->error = $moline->error; + $this->errors = $moline->errors; + dol_print_error($this->db, $moline->error, $moline->errors); + } - // Lines to consume - if (!$error) { - foreach ($bom->lines as $line) - { - $moline = new MoLine($this->db); + if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume. + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + $bom = new Bom($this->db); + $bom->fetch($this->fk_bom); + if ($bom->id > 0) + { + // Lines to consume + if (! $error) { + foreach ($bom->lines as $line) + { + $moline = new MoLine($this->db); - $moline->fk_mo = $this->id; - if ($line->qty_frozen) { - $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce - } else { - $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); - } - if ($moline->qty <= 0) { - $error++; - $this->error = "BadValueForquantityToConsume"; - break; - } - else { - $moline->fk_product = $line->fk_product; - $moline->role = 'toconsume'; - $moline->position = $line->position; - $moline->qty_frozen = $line->qty_frozen; - $moline->disable_stock_change = $line->disable_stock_change; - - $resultline = $moline->create($user, false); // Never use triggers here - if ($resultline <= 0) { + $moline->fk_mo = $this->id; + if ($line->qty_frozen) { + $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce + } else { + $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); + } + if ($moline->qty <= 0) { $error++; - $this->error = $moline->error; - $this->errors = $moline->errors; - dol_print_error($this->db, $moline->error, $moline->errors); + $this->error = "BadValueForquantityToConsume"; break; } + else { + $moline->fk_product = $line->fk_product; + $moline->role = 'toconsume'; + $moline->position = $line->position; + $moline->qty_frozen = $line->qty_frozen; + $moline->disable_stock_change = $line->disable_stock_change; + + $resultline = $moline->create($user, false); // Never use triggers here + if ($resultline <= 0) { + $error++; + $this->error = $moline->error; + $this->errors = $moline->errors; + dol_print_error($this->db, $moline->error, $moline->errors); + break; + } + } } } } @@ -1450,6 +1453,11 @@ class MoLine extends CommonObjectLine */ public function create(User $user, $notrigger = false) { + if (empty($this->qty)) { + $this->error = 'BadValueForQty'; + return -1; + } + return $this->createCommon($user, $notrigger); } diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index b57c453b436..39da2051ed6 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -518,7 +518,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''.$langs->trans("ToConsume").''; + print ''.$langs->trans("ProductsToConsume").''; print ''; if (!empty($object->lines)) { @@ -537,7 +537,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''.$langs->trans("ToProduce").''; + print ''.$langs->trans("ProductsToProduce").''; print ''; if (!empty($object->lines)) { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 16658f703dd..5b6db8739d1 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -162,6 +162,25 @@ if (empty($reshook)) $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); @@ -408,21 +427,43 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - // Confirmation of action xxxx - if ($action == 'xxx') + // Confirmation of validation + if ($action == 'validate') { + // We check that object has a temporary ref + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $object->fetch_product(); + $numref = $object->getNextNumRef($object->fk_product); + } else { + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateMo', $numref); + /*if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); + }*/ + $formquestion = array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $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); + if (!empty($conf->mrp->enabled)) + { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $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), + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } // Call Hook formConfirm @@ -513,6 +554,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); if (empty($reshook)) { + // 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").''; + } + } + } + // Consume or produce if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { if ($permissiontoproduce) { @@ -561,7 +619,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { print '
'; print ''; @@ -569,20 +627,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - $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); + if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + $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 '
'; - print ''.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; - print $langs->trans("MovementLabel").':   '; - print $langs->trans("InventoryCode").':

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

'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print '
'; + } } @@ -601,7 +661,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - print load_fiche_titre($langs->trans('Consumption'), '', ''); + $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; + print load_fiche_titre($langs->trans('Consumption'), '', '', 0, '', '', $newlinetext); print '
'; print ''; @@ -620,6 +681,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; + if ($action == 'addconsumeline') { + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->productbatch->enabled) { + print ''; + } + print ''; + } + if (!empty($object->lines)) { $nblinetoconsume = 0; @@ -883,7 +960,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { print "\n"; }
'; + print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2); + print ''; + print ''; + print '