/* * Updating a line in the order */ if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel')) { $tva_tx = GETPOST('tva_tx'); if (GETPOST('price_ht') != '') { $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht')); } else { $ttc = price2num(GETPOST('price_ttc')); $ht = $ttc / (1 + $tva_tx / 100); $price_base_type = 'HT'; } if ($lineid) { $line = new CommandeFournisseurLigne($db); $res = $line->fetch($lineid); if (!$res) { dol_print_error($db); } } $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) {
unset($_POST['date_endmin']); unset($_POST['date_endsec']); unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); if ($saltar) { header("Refresh:0"); } } else { setEventMessage($object->error, 'errors'); } } else { if ($action == 'update_line' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel')) { if ($_POST["elrowid"]) { $line = new CommandeFournisseurLigne($db); $res = $line->fetch($_POST["elrowid"]); if (!$res) { dol_print_error($db); } } $localtax1_tx = get_localtax($_POST['tva_tx'], 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($_POST['tva_tx'], 2, $mysoc, $object->thirdparty); $result = $object->updateline($_POST['elrowid'], $_POST['eldesc'], $_POST['pu'], $_POST['qty'], $_POST['remise_percent'], $_POST['tva_tx'], $localtax1_tx, $localtax2_tx, 'HT', 0, isset($_POST["type"]) ? $_POST["type"] : $line->product_type); unset($_POST['qty']); unset($_POST['type']); unset($_POST['idprodfournprice']); unset($_POST['remmise_percent']); unset($_POST['dp_desc']); unset($_POST['np_desc']); unset($_POST['pu']); unset($_POST['tva_tx']);
/** * Mise a jour des totaux lignes de commande fournisseur * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @return void */ function migrate_price_commande_fournisseur($db, $langs, $conf) { $db->begin(); print '<tr><td colspan="4">'; print '<br>'; print '<b>' . $langs->trans('MigrationSupplierOrder') . "</b><br>\n"; // Liste des lignes commande non a jour $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,"; $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd, " . MAIN_DB_PREFIX . "commande_fournisseur as c"; $sql .= " WHERE cd.fk_commande = c.rowid"; $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; $qty = $obj->qty; $pu = $obj->subprice; $txtva = $obj->tva_taux; $remise_percent = $obj->remise_percent; $remise_percent_global = $obj->remise_percent_global; $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs $commandeligne = new CommandeFournisseurLigne($db); $commandeligne->fetch($rowid); $result = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, $remise_percent_global, 'HT', $info_bits, 0); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; $commandeligne->total_ht = $total_ht; $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; dolibarr_install_syslog("upgrade2: Line {$rowid}: commandeid={$obj->rowid} pu={$pu} qty={$qty} tva_taux={$txtva} remise_percent={$remise_percent} remise_global={$remise_percent_global} -> {$total_ht}, {$total_tva}, {$total_ttc}"); print ". "; $commandeligne->update_total(); /* On touche pas a facture mere $commande = new Commande($db); $commande->id = $obj->rowid; if ( $commande->fetch($commande->id) >= 0 ) { if ( $commande->update_price() > 0 ) { print ". "; } else { print "Error id=".$commande->id; } } else { print "Error #3"; } */ $i++; } } else { print $langs->trans("AlreadyDone"); } $db->free($resql); /* $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; $resql=$db->query($sql); if (! $resql) { dol_print_error($db); } */ $db->commit(); } else { print "Error #1 " . $db->error(); $db->rollback(); } print '<br>'; print '</td></tr>'; }