|
@@ -438,7 +438,7 @@ if (empty($reshook))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$qualified_for_stock_change = 0;
|
|
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
|
|
|
$qualified_for_stock_change = $object->hasProductsOrServices(2);
|
|
@@ -1022,7 +1022,7 @@ if (empty($reshook))
|
|
|
|
|
|
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines or deposit lines");
|
|
|
$result = $srcobject->fetch($object->origin_id);
|
|
|
-
|
|
|
+
|
|
|
// If deposit invoice
|
|
|
if ($_POST['type'] == Facture::TYPE_DEPOSIT)
|
|
|
{
|
|
@@ -1183,7 +1183,7 @@ if (empty($reshook))
|
|
|
$error ++;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Now we create same links to contact than the ones found on origin object
|
|
|
if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
|
|
|
{
|
|
@@ -1196,13 +1196,13 @@ if (empty($reshook))
|
|
|
}
|
|
|
$sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
|
|
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
|
|
|
-
|
|
|
+
|
|
|
$resqlcontact = $db->query($sqlcontact);
|
|
|
if ($resqlcontact)
|
|
|
{
|
|
|
while($objcontact = $db->fetch_object($resqlcontact))
|
|
|
{
|
|
|
- //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n";
|
|
|
+ //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n";
|
|
|
$object->add_contact($objcontact->fk_socpeople, $objcontact->code);
|
|
|
}
|
|
|
}
|
|
@@ -1214,14 +1214,17 @@ if (empty($reshook))
|
|
|
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
|
|
|
// modified by hook
|
|
|
if ($reshook < 0)
|
|
|
+ {
|
|
|
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
$error++;
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
$error++;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
+ }
|
|
|
+ else
|
|
|
{ // If some invoice's lines coming from page
|
|
|
$id = $object->create($user);
|
|
|
|
|
@@ -1393,7 +1396,7 @@ if (empty($reshook))
|
|
|
// Ecrase $txtva par celui du produit
|
|
|
// Ecrase $base_price_type par celui du produit
|
|
|
// Replaces $fk_unit with the product's
|
|
|
- if (! empty($idprod))
|
|
|
+ if (! empty($idprod))
|
|
|
{
|
|
|
$prod = new Product($db);
|
|
|
$prod->fetch($idprod);
|
|
@@ -1404,7 +1407,7 @@ if (empty($reshook))
|
|
|
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
|
|
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
|
|
if (empty($tva_tx)) $tva_npr=0;
|
|
|
-
|
|
|
+
|
|
|
$pu_ht = $prod->price;
|
|
|
$pu_ttc = $prod->price_ttc;
|
|
|
$price_min = $prod->price_min;
|
|
@@ -1451,13 +1454,13 @@ if (empty($reshook))
|
|
|
}
|
|
|
// On reevalue prix selon taux tva car taux tva transaction peut etre different
|
|
|
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
|
|
|
- elseif ($tva_tx != $prod->tva_tx)
|
|
|
+ elseif ($tva_tx != $prod->tva_tx)
|
|
|
{
|
|
|
- if ($price_base_type != 'HT')
|
|
|
+ if ($price_base_type != 'HT')
|
|
|
{
|
|
|
$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
|
|
|
}
|
|
@@ -1519,7 +1522,7 @@ if (empty($reshook))
|
|
|
// Local Taxes
|
|
|
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
|
|
|
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
|
|
|
-
|
|
|
+
|
|
|
$info_bits = 0;
|
|
|
if ($tva_npr)
|
|
|
$info_bits |= 0x01;
|
|
@@ -1623,7 +1626,7 @@ if (empty($reshook))
|
|
|
// Add buying price
|
|
|
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
|
|
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
|
|
|
-
|
|
|
+
|
|
|
// Extrafields
|
|
|
$extrafieldsline = new ExtraFields($db);
|
|
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
|
@@ -2082,7 +2085,7 @@ if ($action == 'create')
|
|
|
$invoice_predefined->fetch(GETPOST('fac_rec','int'));
|
|
|
|
|
|
$dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later
|
|
|
-
|
|
|
+
|
|
|
$sql = 'SELECT r.rowid, r.titre, r.total_ttc';
|
|
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r';
|
|
|
$sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid;
|
|
@@ -3087,7 +3090,7 @@ else if ($id > 0 || ! empty($ref))
|
|
|
// Remise dispo de type avoir
|
|
|
if (! $absolute_discount)
|
|
|
print '<br>';
|
|
|
- // $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer
|
|
|
+ // $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer
|
|
|
$more=' ('.$addcreditnote.')';
|
|
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher
|
|
|
}
|
|
@@ -4038,7 +4041,7 @@ else if ($id > 0 || ! empty($ref))
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="facture/fiche-rec.php?facid=' . $object->id . '&action=create">' . $langs->trans("ChangeIntoRepeatableInvoice") . '</a></div>';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Create a credit note
|
|
|
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $user->rights->facture->creer)
|
|
|
{
|
|
@@ -4193,7 +4196,7 @@ else if ($id > 0 || ! empty($ref))
|
|
|
{
|
|
|
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
|
|
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id);
|
|
|
- }
|
|
|
+ }
|
|
|
$formmail->withfrom = 1;
|
|
|
$liste = array();
|
|
|
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
|
|
@@ -4213,7 +4216,7 @@ else if ($id > 0 || ! empty($ref))
|
|
|
$formmail->withdeliveryreceipt = 1;
|
|
|
$formmail->withcancel = 1;
|
|
|
// Tableau des substitutions
|
|
|
- $formmail->setSubstitFromObject($object);
|
|
|
+ $formmail->setSubstitFromObject($object, $outputlangs);
|
|
|
$formmail->substit['__INVREF__'] = $object->ref;
|
|
|
|
|
|
// Find the good contact adress
|