Ejemplo n.º 1
0
     $numline = $pos;
     $prod = "product_" . $reg[1] . '_' . $reg[2];
     $qty = "qty_" . $reg[1] . '_' . $reg[2];
     $ent = "entrepot_" . $reg[1] . '_' . $reg[2];
     $pu = "pu_" . $reg[1] . '_' . $reg[2];
     // This is unit price including discount
     $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2];
     if (GETPOST($qty) > 0) {
         if (!(GETPOST($ent, 'int') > 0)) {
             dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
             $text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . $numline;
             setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
             $error++;
         }
         if (!$error) {
             $result = $commande->DispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
             if ($result < 0) {
                 setEventMessages($commande->error, $commande->errors, 'errors');
                 $error++;
             }
         }
     }
 }
 if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
     $pos++;
     //eat-by date dispatch
     //$numline=$reg[2] + 1;	// line of product
     $numline = $pos;
     $prod = 'product_batch_' . $reg[1] . '_' . $reg[2];
     $qty = 'qty_' . $reg[1] . '_' . $reg[2];
     $ent = 'entrepot_' . $reg[1] . '_' . $reg[2];
Ejemplo n.º 2
0
if ($_POST["action"] ==	'dispatch' && $user->rights->fournisseur->commande->receptionner)
{
	$commande = new CommandeFournisseur($db);
	$commande->fetch($_GET["id"]);

	foreach($_POST as $key => $value)
	{
		if ( preg_match('/^product_([0-9]+)$/i', $key, $reg) )
		{
			$prod = "product_".$reg[1];
			$qty = "qty_".$reg[1];
			$ent = "entrepot_".$reg[1];
			$pu = "pu_".$reg[1];
			if ($_POST[$ent] > 0)
			{
				$result = $commande->DispatchProduct($user, $_POST[$prod], $_POST[$qty], $_POST[$ent], $_POST[$pu], $_POST["comment"]);
			}
			else
			{
				dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
			}
		}
	}

	if ($result > 0)
	{
		Header("Location: dispatch.php?id=".$_GET["id"]);
		exit;
	}
	else
	{
/*
 * Actions
 */
if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->receptionner) {
    $commande = new CommandeFournisseur($db);
    $commande->fetch($id);
    $db->begin();
    foreach ($_POST as $key => $value) {
        if (preg_match('/^product_([0-9]+)$/i', $key, $reg)) {
            $prod = "product_" . $reg[1];
            $qty = "qty_" . $reg[1];
            $ent = "entrepot_" . $reg[1];
            $pu = "pu_" . $reg[1];
            // This is unit price including discount
            if (GETPOST($ent, 'int') > 0) {
                $result = $commande->DispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST("comment"));
            } else {
                dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
                $text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . '' . ($reg[1] - 1);
                setEventMessage($langs->trans('ErrorFieldRequired', $text), 'errors');
            }
        } else {
            if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
                //eat-by date dispatch
                $prod = "product_" . $reg[1] . "_" . $reg[2];
                $qty = "qty_" . $reg[1] . "_" . $reg[2];
                $ent = "entrepot_" . $reg[1] . "_" . $reg[2];
                $pu = "pu_" . $reg[1] . "_" . $reg[2];
                $lot = "lot_number_" . $reg[1] . "_" . $reg[2];
                $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_' . $reg[1] . "_" . $reg[2] . 'month'], $_POST['dluo_' . $reg[1] . "_" . $reg[2] . 'day'], $_POST['dluo_' . $reg[1] . "_" . $reg[2] . 'year']);
                $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_' . $reg[1] . "_" . $reg[2] . 'month'], $_POST['dlc_' . $reg[1] . "_" . $reg[2] . 'day'], $_POST['dlc_' . $reg[1] . "_" . $reg[2] . 'year']);