'.$langs->trans("EnableMultilangInterface").' ';
print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
@@ -186,7 +186,7 @@ if ($action == 'edit') // Edit
show_theme(null,1);
print ' ';
- // Liste des zone de recherche permanantes supportees
+ // List of permanent supported search box
if (! empty($searchform))
{
print '';
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index 6281307218c..8af76ce8647 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -215,7 +215,8 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr
$form = new Form($db);
$formother = new FormOther($db);
-llxHeader("","",$langs->trans("Categories"));
+$helpurl='';
+llxHeader("",$langs->trans("Categories"),$helpurl);
if ($user->rights->categorie->creer)
{
@@ -244,7 +245,7 @@ if ($user->rights->categorie->creer)
// Ref
print '';
- print ''.$langs->trans("Ref").' ';
+ print ''.$langs->trans("Ref").' ';
print' ';
// Description
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 09fda82223b..f5cb88f85f4 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -169,7 +169,8 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory'
$form = new Form($db);
$formother = new FormOther($db);
-llxHeader("","",$langs->trans("Categories"));
+$helpurl='';
+llxHeader("",$langs->trans("Categories"),$helpurl);
if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort");
elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort");
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index d5d41dad0a2..82223887b91 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -279,7 +279,7 @@ if (empty($reshook))
if ($socid < 1) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
-
+
$action = 'create';
$error ++;
}
@@ -345,7 +345,7 @@ if (empty($reshook))
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
-
+
// Multicurrency
if (!empty($conf->multicurrency->enabled))
{
@@ -718,7 +718,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;
@@ -932,7 +932,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
+ $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$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'));
@@ -1082,7 +1082,7 @@ if (empty($reshook))
// Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->propal->creer) {
- $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
+ $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
}
// bank account
@@ -1167,12 +1167,12 @@ if (empty($reshook))
}
}
}
-
+
// Actions to build doc
$upload_dir = $conf->propal->dir_output;
$permissioncreate=$user->rights->propal->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
-
+
}
@@ -1266,6 +1266,8 @@ if ($action == 'create')
if ($origin != 'project' && $originid) {
print ' ';
print ' ';
+ } elseif ($origin == 'project' && !empty($projectid)) {
+ print ' ';
}
dol_fiche_head();
@@ -1432,11 +1434,11 @@ if ($action == 'create')
print '';
print ''.fieldLabel('Currency','multicurrency_code').' ';
print '';
- $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
+ $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print ' ';
}
-
+
// Public note
print '';
print '' . $langs->trans('NotePublic') . ' ';
@@ -1934,7 +1936,7 @@ if ($action == 'create')
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
}
print ' ';
-
+
// Multicurrency rate
print '';
print '';
@@ -2053,7 +2055,7 @@ if ($action == 'create')
print ' ' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ' ';
// Margin Infos
- if (! empty($conf->margin->enabled))
+ if (! empty($conf->margin->enabled))
{
$rowspan=4;
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++;
@@ -2087,25 +2089,25 @@ if ($action == 'create')
print ' ' . $langs->trans('AmountTTC') . ' ';
print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ' ';
print ' ';
-
+
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ' ';
print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
print ' ';
-
+
// Multicurrency Amount VAT
print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ' ';
print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
print ' ';
-
+
// Multicurrency Amount TTC
print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ' ';
print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
- print ' ';
+ print '';
}
-
+
// Statut
print '' . $langs->trans('Status') . ' ' . $object->getLibStatut(4) . ' ';
@@ -2394,7 +2396,7 @@ if ($action == 'create')
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id);
- }
+ }
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index f43bd27505a..b8a4aa6d2fa 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -262,14 +262,14 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
-
+
// Fill array 'array_options' with data from add form
if (! $error)
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
}
-
+
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
{
@@ -376,13 +376,38 @@ if (empty($reshook))
$error++;
}
- // Hooks
+ // Now we create same links to contact than the ones found on origin object
+ if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
+ {
+ $originforcontact = $object->origin;
+ $originidforcontact = $object->origin_id;
+ if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
+ {
+ $originforcontact=$srcobject->origin;
+ $originidforcontact=$srcobject->origin_id;
+ }
+ $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";
+ $object->add_contact($objcontact->fk_socpeople, $objcontact->code);
+ }
+ }
+ else dol_print_error($resqlcontact);
+ }
+
+ // Hooks
$parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if ($reshook < 0)
$error++;
-
+
} else {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
@@ -450,12 +475,12 @@ if (empty($reshook))
else if ($action == 'classifyunbilled' && $user->rights->commande->creer)
{
$ret=$object->classifyUnBilled();
-
+
if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
-
+
// Positionne ref commande client
else if ($action == 'set_ref_client' && $user->rights->commande->creer) {
$object->set_ref_client($user, GETPOST('ref_client'));
@@ -500,7 +525,7 @@ if (empty($reshook))
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
-
+
// Multicurrency Code
else if ($action == 'setmulticurrencycode' && $user->rights->commande->creer) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
@@ -508,9 +533,9 @@ if (empty($reshook))
// Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) {
- $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
+ $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
}
-
+
else if ($action == 'setavailability' && $user->rights->commande->creer) {
$result = $object->availability(GETPOST('availability_id'));
if ($result < 0)
@@ -1309,7 +1334,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$remise_absolue = 0;
$currency_code = $conf->currency;
-
+
if (! empty($origin) && ! empty($originid)) {
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
@@ -1380,7 +1405,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (!empty($conf->multicurrency->enabled))
{
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
- if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
+ if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
}
$note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null));
@@ -1403,7 +1428,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$remise_absolue = 0;
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:'';
$projectid = 0;
-
+
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
$note_private = $object->getDefaultCreateValueFor('note_private');
@@ -1671,12 +1696,12 @@ if ($action == 'create' && $user->rights->commande->creer)
}
print '' . $langs->trans('TotalTTC') . ' ' . price($objectsrc->total_ttc) . " ";
-
+
if (!empty($conf->multicurrency->enabled))
{
print '' . $langs->trans('MulticurrencyTotalHT') . ' ' . price($objectsrc->multicurrency_total_ht) . ' ';
print '' . $langs->trans('MulticurrencyTotalVAT') . ' ' . price($objectsrc->multicurrency_total_tva) . " ";
- print '' . $langs->trans('MulticurrencyTotalTTC') . ' ' . price($objectsrc->multicurrency_total_ttc) . " ";
+ print '' . $langs->trans('MulticurrencyTotalTTC') . ' ' . price($objectsrc->multicurrency_total_ttc) . " ";
}
}
else
@@ -1722,7 +1747,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print ' ';
print ' ';
print '';
-
+
print '';
// Show origin lines
@@ -1993,7 +2018,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
print '';
}
-
+
// Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final
@@ -2178,7 +2203,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
}
print '';
-
+
// Multicurrency rate
print '';
print '';
@@ -2244,8 +2269,8 @@ if ($action == 'create' && $user->rights->commande->creer)
print ' / ';
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
print ' ';
- }
-
+ }
+
// TODO How record was recorded OrderMode (llx_c_input_method)
// Project
@@ -2360,16 +2385,16 @@ if ($action == 'create' && $user->rights->commande->creer)
print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ' ';
print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
print ' ';
-
+
// Multicurrency Amount VAT
print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ' ';
print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
print ' ';
-
+
// Multicurrency Amount TTC
print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ' ';
print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ' ';
- print ' ';
+ print '';
}
// Statut
diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php
index 3eb4764bb11..10c52e657ab 100644
--- a/htdocs/compta/bank/account.php
+++ b/htdocs/compta/bank/account.php
@@ -366,16 +366,11 @@ if ($id > 0 || ! empty($ref))
{
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
{
- if (empty($conf->accounting->enabled))
- {
- if ($user->rights->banque->modifier) {
- print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").' ';
- } else {
- print ''.$langs->trans("AddBankRecord").' ';
- }
- } else {
- print ''.$langs->trans("AddBankRecord").' ';
- }
+ if ($user->rights->banque->modifier) {
+ print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").' ';
+ } else {
+ print ''.$langs->trans("AddBankRecord").' ';
+ }
} else {
print ''.$langs->trans("AddBankRecord").' ';
}
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index d4de4e5efb1..a29a0d768bd 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -507,7 +507,11 @@ if ($action == 'create')
dol_fiche_end();
- print '
';
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print '
';
print '';
}
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index 3f794491566..4813d742ad5 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("compta");
$langs->load("bills");
@@ -45,6 +46,8 @@ $year=GETPOST("year",'int');
$filtre=GETPOST("filtre",'alpha');
if (! $year && $mode != 'sconly') { $year=date("Y", time()); }
+$search_account = GETPOST('search_account','int');
+
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@@ -65,6 +68,7 @@ $tva_static = new Tva($db);
$socialcontrib=new ChargeSociales($db);
$payment_sc_static=new PaymentSocialContribution($db);
$sal_static = new PaymentSalary($db);
+$accountstatic = new Account($db);
llxHeader('',$langs->trans("SpecialExpensesArea"));
@@ -122,17 +126,21 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pc.rowid","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pc.datep","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
+ if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pc.amount","",$param,'align="right"',$sortfield,$sortorder);
print "\n";
$sql = "SELECT c.id, c.libelle as lib,";
$sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
- $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,";
- $sql.= " pct.code as payment_code";
+ $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
+ $sql.= " pct.code as payment_code,";
+ $sql.= " ba.rowid as bid, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND cs.entity = ".$conf->entity;
if ($year > 0)
@@ -189,6 +197,20 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print '';
if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
print $obj->num_payment.' ';
+ // Account
+ if (! empty($conf->banque->enabled))
+ {
+ print '';
+ if ($obj->fk_bank > 0)
+ {
+ //$accountstatic->fetch($obj->fk_bank);
+ $accountstatic->id=$obj->bid;
+ $accountstatic->label=$obj->blabel;
+ print $accountstatic->getNomUrl(1);
+ }
+ else print ' ';
+ print ' ';
+ }
// Paid
print '';
if ($obj->totalpaye) print price($obj->totalpaye);
@@ -205,6 +227,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print ' ';
print ' ';
print ' ';
+ if (! empty($conf->banque->enabled)) print ' ';
print ''.price($totalpaye)." ";
print "";
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index eb1a78c8732..a3ead34c8fc 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -282,9 +282,9 @@ if (empty($reshook))
// Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) {
- $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
+ $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
}
-
+
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
@@ -312,7 +312,7 @@ if (empty($reshook))
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
}
-
+
else if ($action == 'setconditions' && $user->rights->facture->creer)
{
$object->fetch($id);
@@ -705,7 +705,7 @@ if (empty($reshook))
}
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
-
+
if (! $error) {
// This is a replacement invoice
$result = $object->fetch($_POST['fac_replacement']);
@@ -758,7 +758,7 @@ if (empty($reshook))
}
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
-
+
if (! $error)
{
$object->socid = GETPOST('socid','int');
@@ -780,7 +780,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
-
+
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
$object->type = Facture::TYPE_CREDIT_NOTE;
@@ -867,7 +867,7 @@ if (empty($reshook))
}
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
-
+
if (! $error)
{
$object->socid = GETPOST('socid','int');
@@ -891,7 +891,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
-
+
// Source facture
$object->fac_rec = GETPOST('fac_rec');
@@ -917,7 +917,7 @@ if (empty($reshook))
}
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
-
+
if (! $error)
{
// Si facture standard
@@ -1176,7 +1176,32 @@ 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))
+ {
+ $originforcontact = $object->origin;
+ $originidforcontact = $object->origin_id;
+ if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
+ {
+ $originforcontact=$srcobject->origin;
+ $originidforcontact=$srcobject->origin_id;
+ }
+ $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";
+ $object->add_contact($objcontact->fk_socpeople, $objcontact->code);
+ }
+ }
+ else dol_print_error($resqlcontact);
+ }
+
// Hooks
$parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
@@ -1186,7 +1211,7 @@ if (empty($reshook))
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$error++;
}
-
+
} else {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
@@ -1218,7 +1243,7 @@ if (empty($reshook))
}
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
-
+
if (!($_POST['situations'] > 0)) {
$error++;
$mesg = '' . $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation")) . '
';
@@ -1233,8 +1258,8 @@ if (empty($reshook))
{
$object->origin = $origin;
$object->origin_id = $originid;
-
- foreach ($object->lines as &$line)
+
+ foreach ($object->lines as &$line)
{
$line->origin = $object->origin;
$line->origin_id = $line->id;
@@ -1580,7 +1605,7 @@ if (empty($reshook))
$pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
-
+
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
@@ -1765,7 +1790,7 @@ if (empty($reshook))
$upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
-
+
if ($action == 'update_extras') {
// Fill array 'array_options' with data from add form
@@ -1872,7 +1897,7 @@ if ($action == 'create')
$res = $soc->fetch($socid);
$currency_code = $conf->currency;
-
+
// Load objectsrc
$remise_absolue = 0;
@@ -1944,9 +1969,9 @@ if ($action == 'create')
if (!empty($conf->multicurrency->enabled))
{
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
- if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
+ if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
}
-
+
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
@@ -1960,7 +1985,7 @@ if ($action == 'create')
$remise_percent = $soc->remise_percent;
$remise_absolue = 0;
$dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970)
-
+
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
}
@@ -1986,7 +2011,7 @@ if ($action == 'create')
}
print info_admin($text, 0, 0, 0).' ';
}
-
+
print '