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 '
';
- 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 ' |