| ';
if (! empty($tabcond[$i]))
{
print ''.$langs->trans($tablib[$i]).'';
@@ -1299,6 +1307,7 @@ function fieldList($fieldlist,$obj='',$tabname='')
print ' | ';
$size='';
if ($fieldlist[$field]=='libelle') $size='size="32" ';
+ if ($fieldlist[$field]=='tracking') $size='size="92" ';
if ($fieldlist[$field]=='accountancy_code') $size='size="15" ';
if ($fieldlist[$field]=='accountancy_code_sell') $size='size="15" ';
if ($fieldlist[$field]=='accountancy_code_buy') $size='size="15" ';
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index 34535b1d321..28e5b912de2 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -201,10 +201,6 @@ $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
$head[$h][1] = $langs->trans("Setup");
$h++;
-$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
-$head[$h][1] = $langs->trans("Carriers");
-$h++;
-
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
$head[$h][1] = $langs->trans("Sending");
$hselected=$h;
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index 49cbeee9026..677e2b3773b 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -189,10 +189,6 @@ $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
$head[$h][1] = $langs->trans("Setup");
$h++;
-$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
-$head[$h][1] = $langs->trans("Carriers");
-$h++;
-
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 4440d632b2e..acdf756eb86 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -194,7 +194,7 @@ asort($orders);
$nbofactivatedmodules=count($conf->modules);
$moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1));
-
+if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'setup');
// Start to show page
@@ -206,7 +206,7 @@ if ($mode==='functional') print $langs->trans("ModulesJobDesc")." \n";
if ($mode==='marketplace') print $langs->trans("ModulesMarketPlaceDesc")." \n";
if ($mode==='expdev') print $langs->trans("ModuleFamilyExperimental")." \n";
-if ($nbofactivatedmodules <= 1) print ' '.img_warning($langs->trans("YouMustEnableOneModule"));
+
//print ' '."\n";
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 590901a937a..2a02522bbcc 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -794,6 +794,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
}
}
+
+
// Standard or deposit or proforma invoice
if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0)
{
@@ -872,126 +874,197 @@ else if ($action == 'add' && $user->rights->facture->creer)
if ($id > 0)
{
- dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
-
- $classname = ucfirst($subelement);
- $srcobject = new $classname($db);
-
- dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
- $result=$srcobject->fetch($object->origin_id);
- if ($result > 0)
- {
- $lines = $srcobject->lines;
- if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
-
- $fk_parent_line=0;
- $num=count($lines);
-
- for ($i=0;$i<$num;$i++)
- {
- $label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
- $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
-
- if ($lines[$i]->subprice < 0)
+ //If deposit invoice
+ if ($_POST['type'] == 3) {
+ $typeamount=GETPOST('typedeposit','alpha');
+ $valuedeposit=GETPOST('valuedeposit','int');
+
+ if ($typeamount=='amount') {
+ $amountdeposit=$valuedeposit;
+ }else {
+ $amountdeposit=0;
+
+ dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
+
+ $classname = ucfirst($subelement);
+ $srcobject = new $classname($db);
+
+ dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit line");
+ $result=$srcobject->fetch($object->origin_id);
+ if ($result > 0)
{
- // Negative line, we create a discount line
- $discount = new DiscountAbsolute($db);
- $discount->fk_soc=$object->socid;
- $discount->amount_ht=abs($lines[$i]->total_ht);
- $discount->amount_tva=abs($lines[$i]->total_tva);
- $discount->amount_ttc=abs($lines[$i]->total_ttc);
- $discount->tva_tx=$lines[$i]->tva_tx;
- $discount->fk_user=$user->id;
- $discount->description=$desc;
- $discountid=$discount->create($user);
- if ($discountid > 0)
+ $totalamount=0;
+ $lines = $srcobject->lines;
+ $num=count($lines);
+ for ($i=0;$i<$num;$i++)
{
- $result=$object->insert_discount($discountid); // This include link_to_invoice
+ $totalamount=+$lines[$i]->subprice;
}
- else
- {
- $mesgs[]=$discount->error;
- $error++;
- break;
+
+ if ($totalamount!=0) {
+ $amountdeposit=($totalamount*$valuedeposit)/100;
}
}
else
{
- // Positive line
- $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
+ $mesgs[]=$srcobject->error;
+ $error++;
+ }
+
+ }
+
+ $result = $object->addline(
+ $id,
+ $langs->trans('Deposit'),
+ $amountdeposit, //subprice
+ 1, //quantity
+ $lines[$i]->tva_tx,
+ 0, //localtax1_tx
+ 0, //localtax2_tx
+ 0, //fk_product
+ 0, //remise_percent
+ 0, //date_start
+ 0, //date_end
+ 0,
+ $lines[$i]->info_bits, //info_bits
+ 0, //info_bits
+ 'HT',
+ 0,
+ 0, //product_type
+ 1,
+ $lines[$i]->special_code,
+ $object->origin,
+ 0,
+ 0,
+ 0,
+ 0,
+ $langs->trans('Deposit')
+ );
+
- // Date start
- $date_start=false;
- if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
- if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
- if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
+ }else {
- //Date end
- $date_end=false;
- if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
- if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
- if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
+ dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
- // Reset fk_parent_line for no child products and special product
- if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
- $fk_parent_line = 0;
- }
+ $classname = ucfirst($subelement);
+ $srcobject = new $classname($db);
- $result = $object->addline(
- $id,
- $desc,
- $lines[$i]->subprice,
- $lines[$i]->qty,
- $lines[$i]->tva_tx,
- $lines[$i]->localtax1_tx,
- $lines[$i]->localtax2_tx,
- $lines[$i]->fk_product,
- $lines[$i]->remise_percent,
- $date_start,
- $date_end,
- 0,
- $lines[$i]->info_bits,
- $lines[$i]->fk_remise_except,
- 'HT',
- 0,
- $product_type,
- $lines[$i]->rang,
- $lines[$i]->special_code,
- $object->origin,
- $lines[$i]->rowid,
- $fk_parent_line,
- $lines[$i]->fk_fournprice,
- $lines[$i]->pa_ht,
- $label
- );
+ dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
+ $result=$srcobject->fetch($object->origin_id);
+ if ($result > 0)
+ {
+ $lines = $srcobject->lines;
+ if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
- if ($result > 0)
+ $fk_parent_line=0;
+ $num=count($lines);
+
+ for ($i=0;$i<$num;$i++)
+ {
+ $label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
+ $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
+
+ if ($lines[$i]->subprice < 0)
{
- $lineid=$result;
+ // Negative line, we create a discount line
+ $discount = new DiscountAbsolute($db);
+ $discount->fk_soc=$object->socid;
+ $discount->amount_ht=abs($lines[$i]->total_ht);
+ $discount->amount_tva=abs($lines[$i]->total_tva);
+ $discount->amount_ttc=abs($lines[$i]->total_ttc);
+ $discount->tva_tx=$lines[$i]->tva_tx;
+ $discount->fk_user=$user->id;
+ $discount->description=$desc;
+ $discountid=$discount->create($user);
+ if ($discountid > 0)
+ {
+ $result=$object->insert_discount($discountid); // This include link_to_invoice
+ }
+ else
+ {
+ $mesgs[]=$discount->error;
+ $error++;
+ break;
+ }
}
else
{
- $lineid=0;
- $error++;
- break;
- }
+ // Positive line
+ $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
- // Defined the new fk_parent_line
- if ($result > 0 && $lines[$i]->product_type == 9) {
- $fk_parent_line = $result;
+ // Date start
+ $date_start=false;
+ if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
+ if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
+ if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
+
+ //Date end
+ $date_end=false;
+ if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
+ if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
+ if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
+
+ // Reset fk_parent_line for no child products and special product
+ if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
+ $fk_parent_line = 0;
+ }
+
+ $result = $object->addline(
+ $id,
+ $desc,
+ $lines[$i]->subprice,
+ $lines[$i]->qty,
+ $lines[$i]->tva_tx,
+ $lines[$i]->localtax1_tx,
+ $lines[$i]->localtax2_tx,
+ $lines[$i]->fk_product,
+ $lines[$i]->remise_percent,
+ $date_start,
+ $date_end,
+ 0,
+ $lines[$i]->info_bits,
+ $lines[$i]->fk_remise_except,
+ 'HT',
+ 0,
+ $product_type,
+ $lines[$i]->rang,
+ $lines[$i]->special_code,
+ $object->origin,
+ $lines[$i]->rowid,
+ $fk_parent_line,
+ $lines[$i]->fk_fournprice,
+ $lines[$i]->pa_ht,
+ $label
+ );
+
+ if ($result > 0)
+ {
+ $lineid=$result;
+ }
+ else
+ {
+ $lineid=0;
+ $error++;
+ break;
+ }
+
+ // Defined the new fk_parent_line
+ if ($result > 0 && $lines[$i]->product_type == 9) {
+ $fk_parent_line = $result;
+ }
}
}
- }
- // 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
- {
- $mesgs[]=$srcobject->error;
- $error++;
+ // 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
+ {
+ $mesgs[]=$srcobject->error;
+ $error++;
+ }
}
}
else
@@ -1513,7 +1586,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// if (is_readable($file))
- // {
+ // {
if ($_POST['sendto'])
{
// Le destinataire a ete fourni via le champ libre
@@ -1658,2055 +1731,2061 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$mesgs[]=''.$langs->trans('ErrorCantReadFile',$file).' ';
dol_syslog('Failed to read file: '.$file);
}
- }
- else
- {
- $langs->load("other");
- $mesgs[]=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).' ';
- dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
- }
-
- $action = 'presend';
+ }
+ else
+ {
+ $langs->load("other");
+ $mesgs[]=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).' ';
+ dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
}
- /*
- * Generate document
- */
- else if ($action == 'builddoc') // En get ou en post
+ $action = 'presend';
+}
+
+/*
+ * Generate document
+*/
+else if ($action == 'builddoc') // En get ou en post
+{
+ $object->fetch($id);
+ $object->fetch_thirdparty();
+
+ if (GETPOST('model')) $object->setDocModel($user, GETPOST('model'));
+ if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank');
+
+ // Define output language
+ $outputlangs = $langs;
+ $newlang='';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
{
- $object->fetch($id);
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ if ($result <= 0)
+ {
+ dol_print_error($db,$result);
+ exit;
+ }
+ else
+ {
+ header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
+ exit;
+ }
+}
+
+// Remove file in doc form
+else if ($action == 'remove_file')
+{
+ if ($object->fetch($id))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
$object->fetch_thirdparty();
- if (GETPOST('model')) $object->setDocModel($user, GETPOST('model'));
- if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank');
+ $langs->load("other");
+ $upload_dir = $conf->facture->dir_output;
+ $file = $upload_dir . '/' . GETPOST('file');
+ $ret=dol_delete_file($file,0,0,0,$object);
+ if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
+ else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+ $action='';
+ }
+}
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
+{
+ if ($action == 'addcontact')
+ {
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
{
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
+ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+ $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
- $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- if ($result <= 0)
+
+ if ($result >= 0)
{
- dol_print_error($db,$result);
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
- header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
- exit;
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ $langs->load("errors");
+ $mesgs[] = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").' ';
+ }
+ else
+ {
+ $mesgs[] = ''.$object->error.' ';
+ }
}
}
- // Remove file in doc form
- else if ($action == 'remove_file')
+ // bascule du statut d'un contact
+ else if ($action == 'swapstatut')
{
if ($object->fetch($id))
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $object->fetch_thirdparty();
-
- $langs->load("other");
- $upload_dir = $conf->facture->dir_output;
- $file = $upload_dir . '/' . GETPOST('file');
- $ret=dol_delete_file($file,0,0,0,$object);
- if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
- else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
- $action='';
- }
- }
-
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
- {
- if ($action == 'addcontact')
- {
- $result = $object->fetch($id);
-
- if ($result > 0 && $id > 0)
- {
- $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
- }
-
- if ($result >= 0)
- {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else
- {
- if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
- $langs->load("errors");
- $mesgs[] = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").' ';
- }
- else
- {
- $mesgs[] = ''.$object->error.' ';
- }
- }
- }
-
- // bascule du statut d'un contact
- else if ($action == 'swapstatut')
- {
- if ($object->fetch($id))
- {
- $result=$object->swapContactStatus(GETPOST('ligne'));
- }
- else
- {
- dol_print_error($db);
- }
- }
-
- // Efface un contact
- else if ($action == 'deletecontact')
- {
- $object->fetch($id);
- $result = $object->delete_contact($lineid);
-
- if ($result >= 0)
- {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else {
- dol_print_error($db);
- }
- }
- }
-
- if ($action == 'update_extras')
- {
- // Fill array 'array_options' with data from add form
- $extralabels=$extrafields->fetch_name_optionals_label('facture');
- $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
-
- // Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
- $hookmanager->initHooks(array('invoicedao'));
- $parameters=array('id'=>$object->id);
- $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
- if (empty($reshook))
- {
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
- $result=$object->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
- }
- else if ($reshook < 0) $error++;
-
- }
-
-
- /*
- * View
- */
-
- $form = new Form($db);
- $formother=new FormOther($db);
- $formfile = new FormFile($db);
- $bankaccountstatic=new Account($db);
- $now=dol_now();
-
- llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
-
-
-
- /*********************************************************************
- *
- * Mode creation
- *
- **********************************************************************/
- if ($action == 'create')
- {
- $facturestatic=new Facture($db);
- $extralabels=$extrafields->fetch_name_optionals_label('facture');
-
- print_fiche_titre($langs->trans('NewBill'));
-
- $soc = new Societe($db);
- if ($socid>0) $res=$soc->fetch($socid);
-
- if (! empty($origin) && ! empty($originid))
- {
- // Parse element/subelement (ex: project_task)
- $element = $subelement = $origin;
- if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs))
- {
- $element = $regs[1];
- $subelement = $regs[2];
- }
-
- if ($element == 'project')
- {
- $projectid=$originid;
- }
- else
- {
- // For compatibility
- if ($element == 'order' || $element == 'commande') {
- $element = $subelement = 'commande';
- }
- if ($element == 'propal') {
- $element = 'comm/propal'; $subelement = 'propal';
- }
- if ($element == 'contract') {
- $element = $subelement = 'contrat';
- }
- if ($element == 'shipping') {
- $element = $subelement = 'expedition';
- }
-
- dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
-
- $classname = ucfirst($subelement);
- $objectsrc = new $classname($db);
- $objectsrc->fetch($originid);
- if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
- $objectsrc->fetch_thirdparty();
-
- $projectid = (! empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
- $ref_client = (! empty($objectsrc->ref_client)?$objectsrc->ref_client:'');
- $ref_int = (! empty($objectsrc->ref_int)?$objectsrc->ref_int:'');
-
- $soc = $objectsrc->thirdparty;
- $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
- $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
- $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
- $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
- $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
- }
+ $result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
- $cond_reglement_id = $soc->cond_reglement_id;
- $mode_reglement_id = $soc->mode_reglement_id;
- $remise_percent = $soc->remise_percent;
- $remise_absolue = 0;
+ dol_print_error($db);
+ }
+ }
+
+ // Efface un contact
+ else if ($action == 'deletecontact')
+ {
+ $object->fetch($id);
+ $result = $object->delete_contact($lineid);
+
+ if ($result >= 0)
+ {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else {
+ dol_print_error($db);
+ }
+ }
+}
+
+if ($action == 'update_extras')
+{
+ // Fill array 'array_options' with data from add form
+ $extralabels=$extrafields->fetch_name_optionals_label('facture');
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+
+ // Actions on extra fields (by external module or standard code)
+ // FIXME le hook fait double emploi avec le trigger !!
+ $hookmanager->initHooks(array('invoicedao'));
+ $parameters=array('id'=>$object->id);
+ $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ if (empty($reshook))
+ {
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ {
+ $result=$object->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
+ }
+ else if ($reshook < 0) $error++;
+
+}
+
+
+/*
+ * View
+*/
+
+$form = new Form($db);
+$formother=new FormOther($db);
+$formfile = new FormFile($db);
+$bankaccountstatic=new Account($db);
+$now=dol_now();
+
+llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
+
+
+
+/*********************************************************************
+ *
+* Mode creation
+*
+**********************************************************************/
+if ($action == 'create')
+{
+ $facturestatic=new Facture($db);
+ $extralabels=$extrafields->fetch_name_optionals_label('facture');
+
+ print_fiche_titre($langs->trans('NewBill'));
+
+ $soc = new Societe($db);
+ if ($socid>0) $res=$soc->fetch($socid);
+
+ if (! empty($origin) && ! empty($originid))
+ {
+ // Parse element/subelement (ex: project_task)
+ $element = $subelement = $origin;
+ if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs))
+ {
+ $element = $regs[1];
+ $subelement = $regs[2];
+ }
+
+ if ($element == 'project')
+ {
+ $projectid=$originid;
+ }
+ else
+ {
+ // For compatibility
+ if ($element == 'order' || $element == 'commande') {
+ $element = $subelement = 'commande';
+ }
+ if ($element == 'propal') {
+ $element = 'comm/propal'; $subelement = 'propal';
+ }
+ if ($element == 'contract') {
+ $element = $subelement = 'contrat';
+ }
+ if ($element == 'shipping') {
+ $element = $subelement = 'expedition';
+ }
+
+ dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
+
+ $classname = ucfirst($subelement);
+ $objectsrc = new $classname($db);
+ $objectsrc->fetch($originid);
+ if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
+ $objectsrc->fetch_thirdparty();
+
+ $projectid = (! empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
+ $ref_client = (! empty($objectsrc->ref_client)?$objectsrc->ref_client:'');
+ $ref_int = (! empty($objectsrc->ref_int)?$objectsrc->ref_int:'');
+
+ $soc = $objectsrc->thirdparty;
+ $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
+ $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
+ $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
+ $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
}
- $absolute_discount=$soc->getAvailableDiscounts();
+ }
+ else
+ {
+ $cond_reglement_id = $soc->cond_reglement_id;
+ $mode_reglement_id = $soc->mode_reglement_id;
+ $remise_percent = $soc->remise_percent;
+ $remise_absolue = 0;
+ $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
+ }
+ $absolute_discount=$soc->getAvailableDiscounts();
- if (! empty($conf->use_javascript_ajax))
+ if (! empty($conf->use_javascript_ajax))
+ {
+ print ajax_combobox('fac_replacement');
+ print ajax_combobox('fac_avoir');
+ }
+
+ print ' |