'.$langs->trans('Type').' ';
- print ''."\n";
-
+
+ print '' . $langs->trans('Type') . ' ';
+ print '' . "\n";
+
// Standard invoice
print '';
- print ' ';
+ print ' ';
print ' ';
- $desc=$form->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1);
+ $desc = $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1);
print $desc;
- print ' '."\n";
-
+ print '' . "\n";
+
// Proforma
- if (! empty($conf->global->FACTURE_USE_PROFORMAT))
- {
+ if (! empty($conf->global->FACTURE_USE_PROFORMAT)) {
print '';
- print ' ';
+ print ' ';
print ' ';
- $desc=$form->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1);
+ $desc = $form->textwithpicto($langs->trans("InvoiceProForma"), $langs->transnoentities("InvoiceProFormaDesc"), 1);
print $desc;
- print ' '."\n";
+ print '' . "\n";
}
-
- if ((empty($origin)) || ((($origin=='propal') || ($origin=='commande')) && (!empty($originid))))
- {
+
+ if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) {
// Deposit
print '';
- print ' ';
+ print ' ';
print ' ';
- $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
- print ''.$desc.' ';
- if (($origin=='propal') || ($origin=='commande'))
- {
+ $desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1);
+ print '' . $desc . ' ';
+ if (($origin == 'propal') || ($origin == 'commande')) {
print '';
- $arraylist=array('amount'=>'FixAmount','variable'=>'VarAmount');
- print $form->selectarray('typedeposit',$arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
+ $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
+ print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
print ' ';
- print ''.$langs->trans('Value').': ';
+ print ' ' . $langs->trans('Value') . ': ';
}
print '
';
- print ' '."\n";
+ print '' . "\n";
}
-
- if ($socid > 0)
- {
+
+ if ($socid > 0) {
// Replacement
print '';
- print ' ';
print ' ';
- $text=$langs->trans("InvoiceReplacementAsk").' ';
- $text.='';
- if ($options)
- {
- $text.=' ';
- $text.=$options;
+ $text = $langs->trans("InvoiceReplacementAsk") . ' ';
+ $text .= 'trans("NoReplacableInvoice") . '';
}
- else
- {
- $text.=''.$langs->trans("NoReplacableInvoice").' ';
- }
- $text.=' ';
- $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1);
+ $text .= ' ';
+ $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1);
print $desc;
- print ' '."\n";
+ print '' . "\n";
}
-
- if (empty($origin) && $socid > 0)
- {
+
+ if (empty($origin) && $socid > 0) {
// Credit note
print '';
- print ' ';
print ' ';
- $text=$langs->transnoentities("InvoiceAvoirAsk").' ';
- // $text.=' ';
- $text.='';
- if ($optionsav)
- {
- $text.=' ';
- $text.=$optionsav;
+ $text = $langs->transnoentities("InvoiceAvoirAsk") . ' ';
+ // $text.=' ';
+ $text .= 'trans("NoInvoiceToCorrect") . '';
}
- else
- {
- $text.=''.$langs->trans("NoInvoiceToCorrect").' ';
- }
- $text.=' ';
- $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1);
+ $text .= ' ';
+ $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
print $desc;
- print ' '."\n";
+ print '' . "\n";
}
-
+
print '
';
print ' ';
-
- if ($socid > 0)
- {
+
+ if ($socid > 0) {
// Discounts for third party
- print ''.$langs->trans('Discounts').' ';
- if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",'id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')).'">'.$soc->remise_percent.' ');
- else print $langs->trans("CompanyHasNoRelativeDiscount");
- print ' id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')).'">('.$langs->trans("EditRelativeDiscount").') ';
+ print ' ' . $langs->trans('Discounts') . ' ';
+ if ($soc->remise_percent)
+ print $langs->trans("CompanyHasRelativeDiscount", 'id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_percent . ' ');
+ else
+ print $langs->trans("CompanyHasNoRelativeDiscount");
+ print ' id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ') ';
print '. ';
print ' ';
- if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",'id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')).'">'.price($absolute_discount).' ',$langs->trans("Currency".$conf->currency));
- else print $langs->trans("CompanyHasNoAbsoluteDiscount");
- print ' id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')).'">('.$langs->trans("EditGlobalDiscounts").') ';
+ if ($absolute_discount)
+ print $langs->trans("CompanyHasAbsoluteDiscount", 'id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . ' ', $langs->trans("Currency" . $conf->currency));
+ else
+ print $langs->trans("CompanyHasNoAbsoluteDiscount");
+ print ' id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ') ';
print '.';
print ' ';
}
-
+
// Date invoice
- print ''.$langs->trans('Date').' ';
- $form->select_date($dateinvoice,'','','','',"add",1,1);
+ print ' ' . $langs->trans('Date') . ' ';
+ $form->select_date($dateinvoice, '', '', '', '', "add", 1, 1);
print ' ';
-
+
// Payment term
- print ''.$langs->trans('PaymentConditionsShort').' ';
- $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
+ print ' ' . $langs->trans('PaymentConditionsShort') . ' ';
+ $form->select_conditions_paiements(isset($_POST ['cond_reglement_id']) ? $_POST ['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
print ' ';
-
+
// Payment mode
- print ''.$langs->trans('PaymentMode').' ';
- $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
+ print ' ' . $langs->trans('PaymentMode') . ' ';
+ $form->select_types_paiements(isset($_POST ['mode_reglement_id']) ? $_POST ['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
print ' ';
-
+
// Project
- if (! empty($conf->projet->enabled) && $socid>0)
- {
- $formproject=new FormProjets($db);
-
+ if (! empty($conf->projet->enabled) && $socid > 0) {
+ $formproject = new FormProjets($db);
+
$langs->load('projects');
- print ''.$langs->trans('Project').' ';
+ print ' ' . $langs->trans('Project') . ' ';
$formproject->select_projects($soc->id, $projectid, 'projectid');
print ' ';
}
-
+
// Other attributes
- $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
- $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
- if (empty($reshook) && ! empty($extrafields->attribute_label))
- {
- print $object->showOptionals($extrafields,'edit');
+ $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
+ // hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label)) {
+ print $object->showOptionals($extrafields, 'edit');
}
-
+
// Modele PDF
- print ''.$langs->trans('Model').' ';
+ print '' . $langs->trans('Model') . ' ';
print '';
- include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
- $liste=ModelePDFFactures::liste_modeles($db);
- print $form->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF);
+ include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
+ $liste = ModelePDFFactures::liste_modeles($db);
+ print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF);
print " ";
-
+
// Public note
print '';
- print ''.$langs->trans('NotePublic').' ';
+ print '' . $langs->trans('NotePublic') . ' ';
print '';
- $note_public='';
- if (is_object($objectsrc)) // Take value from source object
+ $note_public = '';
+ if (is_object($objectsrc)) // Take value from source object
{
- $note_public=$objectsrc->note_public;
+ $note_public = $objectsrc->note_public;
}
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
-
- //print ' ';
-
+
+ // print '';
+
// Private note
- if (empty($user->societe_id))
- {
+ if (empty($user->societe_id)) {
print '';
- print ''.$langs->trans('NotePrivate').' ';
+ print '' . $langs->trans('NotePrivate') . ' ';
print '';
- $note_private='';
- if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object
+ $note_private = '';
+ if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object
{
- $note_private=$objectsrc->note_private;
+ $note_private = $objectsrc->note_private;
}
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
- //print ' ';
+ // print '';
}
-
- if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
- {
+
+ if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
// TODO for compatibility
- if ($origin == 'contrat')
- {
+ if ($origin == 'contrat') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
- $objectsrc->remise_absolue=$remise_absolue;
- $objectsrc->remise_percent=$remise_percent;
- $objectsrc->update_price(1,-1,1);
+ $objectsrc->remise_absolue = $remise_absolue;
+ $objectsrc->remise_percent = $remise_percent;
+ $objectsrc->update_price(1, - 1, 1);
}
-
- print "\n";
+
+ print "\n";
print "\n";
- print ' '."\n";
- print ' '."\n";
- print ' '."\n";
- print ' ';
- print ' ';
-
- $newclassname=$classname;
- if ($newclassname == 'Propal') $newclassname = 'CommercialProposal';
- elseif ($newclassname == 'Commande') $newclassname = 'Order';
- elseif ($newclassname == 'Expedition') $newclassname = 'Sending';
-
- print ''.$langs->trans($newclassname).' '.$objectsrc->getNomUrl(1).' ';
- print ''.$langs->trans('TotalHT').' '.price($objectsrc->total_ht).' ';
- print ''.$langs->trans('TotalVAT').' '.price($objectsrc->total_tva)." ";
- if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
+ print ' ' . "\n";
+ print ' ' . "\n";
+ print ' ' . "\n";
+ print ' ';
+ print ' ';
+
+ $newclassname = $classname;
+ if ($newclassname == 'Propal')
+ $newclassname = 'CommercialProposal';
+ elseif ($newclassname == 'Commande')
+ $newclassname = 'Order';
+ elseif ($newclassname == 'Expedition')
+ $newclassname = 'Sending';
+
+ print '' . $langs->trans($newclassname) . ' ' . $objectsrc->getNomUrl(1) . ' ';
+ print '' . $langs->trans('TotalHT') . ' ' . price($objectsrc->total_ht) . ' ';
+ print '' . $langs->trans('TotalVAT') . ' ' . price($objectsrc->total_tva) . " ";
+ if ($mysoc->localtax1_assuj == "1") // Localtax1 RE
{
- print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).' '.price($objectsrc->total_localtax1)." ";
+ print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax1) . " ";
}
-
- if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
+
+ if ($mysoc->localtax2_assuj == "1") // Localtax2 IRPF
{
- print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).' '.price($objectsrc->total_localtax2)." ";
+ print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax2) . " ";
}
- print ''.$langs->trans('TotalTTC').' '.price($objectsrc->total_ttc)." ";
- }
- else
- {
+ print '' . $langs->trans('TotalTTC') . ' ' . price($objectsrc->total_ttc) . " ";
+ } else {
// Show deprecated optional form to add product line here
- if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE))
- {
+ if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) {
print '';
-
+
// Zone de choix des produits predefinis a la creation
print '';
print '';
- print ''.$langs->trans('ProductsAndServices').' ';
- print ''.$langs->trans('Qty').' ';
- print ''.$langs->trans('ReductionShort').' ';
+ print '' . $langs->trans('ProductsAndServices') . ' ';
+ print '' . $langs->trans('Qty') . ' ';
+ print '' . $langs->trans('ReductionShort') . ' ';
print ' ';
- if (! empty($conf->service->enabled))
- {
- print ''.$langs->trans('ServiceLimitedDuration').' ';
+ if (! empty($conf->service->enabled)) {
+ print '' . $langs->trans('ServiceLimitedDuration') . ' ';
}
print ' ';
- for ($i = 1 ; $i <= $NBLINES ; $i++)
- {
+ for($i = 1; $i <= $NBLINES; $i ++) {
print '';
print '';
// multiprix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
- $form->select_produits('','idprod'.$i,'',$conf->product->limit_size,$soc->price_level);
+ $form->select_produits('', 'idprod' . $i, '', $conf->product->limit_size, $soc->price_level);
else
- $form->select_produits('','idprod'.$i,'',$conf->product->limit_size);
+ $form->select_produits('', 'idprod' . $i, '', $conf->product->limit_size);
print ' ';
- print ' ';
- print ' % ';
+ print ' ';
+ print ' % ';
print ' ';
// Si le module service est actif, on propose des dates de debut et fin a la ligne
- if (! empty($conf->service->enabled))
- {
+ if (! empty($conf->service->enabled)) {
print '';
print '';
print '';
- print $langs->trans('From').' ';
+ print $langs->trans('From') . ' ';
print ' ';
- print $form->select_date('','date_start'.$i,$usehm,$usehm,1,"add");
+ print $form->select_date('', 'date_start' . $i, $usehm, $usehm, 1, "add");
print ' ';
print '';
- print $langs->trans('to').' ';
+ print $langs->trans('to') . ' ';
print ' ';
- print $form->select_date('','date_end'.$i,$usehm,$usehm,1,"add");
+ print $form->select_date('', 'date_end' . $i, $usehm, $usehm, 1, "add");
print '
';
print ' ';
}
print " \n";
}
-
+
print '
';
print ' ';
}
}
-
+
print "
\n";
-
+
// Button "Create Draft"
- print ' ';
-
+ print ' ';
+
print "\n";
-
+
// Show origin lines
- if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
- {
+ if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
print ' ';
-
- $title=$langs->trans('ProductsAndServices');
+
+ $title = $langs->trans('ProductsAndServices');
print_titre($title);
-
+
print '';
-
+
$objectsrc->printOriginLinesList();
-
+
print '
';
}
-
+
print ' ';
-}
-else if ($id > 0 || ! empty($ref))
-{
+} else if ($id > 0 || ! empty($ref)) {
/*
* Show object in view mode
*/
-
- $result=$object->fetch($id,$ref);
- if ($result <= 0) { dol_print_error($db, $object->error); exit; }
-
+
+ $result = $object->fetch($id, $ref);
+ if ($result <= 0) {
+ dol_print_error($db, $object->error);
+ exit();
+ }
+
// fetch optionals attributes and labels
- $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
-
- if ($user->societe_id>0 && $user->societe_id!=$object->socid) accessforbidden('',0);
-
- $result=$object->fetch_thirdparty();
-
+ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+
+ if ($user->societe_id > 0 && $user->societe_id != $object->socid)
+ accessforbidden('', 0);
+
+ $result = $object->fetch_thirdparty();
+
$soc = new Societe($db);
$soc->fetch($object->socid);
- $selleruserevenustamp=$mysoc->useRevenueStamp();
-
- $totalpaye = $object->getSommePaiement();
+ $selleruserevenustamp = $mysoc->useRevenueStamp();
+
+ $totalpaye = $object->getSommePaiement();
$totalcreditnotes = $object->getSumCreditNotesUsed();
$totaldeposits = $object->getSumDepositsUsed();
- //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." selleruserrevenuestamp=".$selleruserevenustamp;
-
+ // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits."
+ // selleruserrevenuestamp=".$selleruserevenustamp;
+
// We can also use bcadd to avoid pb with floating points
// For example print 239.2 - 229.3 - 9.9; does not return 0.
- //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
- //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
- $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
-
- if ($object->paye) $resteapayer=0;
- $resteapayeraffiche=$resteapayer;
-
- 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 invoice
- $filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
+ // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
+ $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
+
+ if ($object->paye)
+ $resteapayer = 0;
+ $resteapayeraffiche = $resteapayer;
+
+ 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 invoice
+ $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ } else {
+ $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
+ $filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
}
- else
- {
- $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
- $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
- }
-
- $absolute_discount=$soc->getAvailableDiscounts('',$filterabsolutediscount);
- $absolute_creditnote=$soc->getAvailableDiscounts('',$filtercreditnote);
- $absolute_discount=price2num($absolute_discount,'MT');
- $absolute_creditnote=price2num($absolute_creditnote,'MT');
-
+
+ $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
+ $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
+ $absolute_discount = price2num($absolute_discount, 'MT');
+ $absolute_creditnote = price2num($absolute_creditnote, 'MT');
+
$author = new User($db);
- if ($object->user_author)
- {
+ if ($object->user_author) {
$author->fetch($object->user_author);
}
-
- $objectidnext=$object->getIdReplacingInvoice();
-
+
+ $objectidnext = $object->getIdReplacingInvoice();
+
$head = facture_prepare_head($object);
-
+
dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), 0, 'bill');
-
- $formconfirm='';
-
+
+ $formconfirm = '';
+
// Confirmation de la conversion de l'avoir en reduc
- if ($action == 'converttoreduc')
- {
- $text=$langs->trans('ConfirmConvertToReduc');
- $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc','',"yes",2);
+ if ($action == 'converttoreduc') {
+ $text = $langs->trans('ConfirmConvertToReduc');
+ $formconfirm = $form->formconfirm($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2);
}
-
+
// Confirmation to delete invoice
- if ($action == 'delete')
- {
- $text=$langs->trans('ConfirmDeleteBill',$object->ref);
- $formquestion=array();
-
- $qualified_for_stock_change=0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(2);
+ if ($action == 'delete') {
+ $text = $langs->trans('ConfirmDeleteBill', $object->ref);
+ $formquestion = array();
+
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
}
- else
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(1);
- }
-
- if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut>=1)
- {
+
+ if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut >= 1) {
$langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $formproduct=new FormProduct($db);
- $label=$object->type==2?$langs->trans("SelectWarehouseForStockDecrease"):$langs->trans("SelectWarehouseForStockIncrease");
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1,0,0,$langs->trans("NoStockAction"))));
- $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete',$formquestion,"yes",1);
- }else {
- $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','','',1);
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ $formproduct = new FormProduct($db);
+ $label = $object->type == 2 ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
+ // 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
+ // => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"))));
+ $formconfirm = $form->formconfirm($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1);
+ } else {
+ $formconfirm = $form->formconfirm($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', '', 1);
}
}
-
+
// Confirmation de la validation
- if ($action == 'valid')
- {
+ if ($action == 'valid') {
// on verifie si l'objet est en numerotation provisoire
$objectref = substr($object->ref, 1, 4);
- if ($objectref == 'PROV')
- {
- $savdate=$object->date;
- if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION))
- {
- $object->date=dol_now();
- $object->date_lim_reglement=$object->calculate_date_lim_reglement();
+ if ($objectref == 'PROV') {
+ $savdate = $object->date;
+ if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
+ $object->date = dol_now();
+ $object->date_lim_reglement = $object->calculate_date_lim_reglement();
}
$numref = $object->getNextNumRef($soc);
- //$object->date=$savdate;
- }
- else
- {
+ // $object->date=$savdate;
+ } else {
$numref = $object->ref;
}
-
- $text=$langs->trans('ConfirmValidateBill',$numref);
- if (! empty($conf->notification->enabled))
- {
- require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
- $notify=new Notify($db);
- $text.=' ';
- $text.=$notify->confirmMessage('BILL_VALIDATE',$object->socid);
+
+ $text = $langs->trans('ConfirmValidateBill', $numref);
+ if (! empty($conf->notification->enabled)) {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
+ $notify = new Notify($db);
+ $text .= ' ';
+ $text .= $notify->confirmMessage('BILL_VALIDATE', $object->socid);
}
- $formquestion=array();
-
- $qualified_for_stock_change=0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(2);
+ $formquestion = array();
+
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
}
- else
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(1);
- }
-
- if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
- {
+
+ if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) {
$langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
- $formproduct=new FormProduct($db);
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
+ $formproduct = new FormProduct($db);
$warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) {
- $label = $object->type==2?$langs->trans("WarehouseForStockIncrease", current($warehouse_array)):$langs->trans("WarehouseForStockDecrease", current($warehouse_array));
+ $label = $object->type == 2 ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
$value = ' ';
} else {
- $label = $object->type==2?$langs->trans("SelectWarehouseForStockIncrease"):$langs->trans("SelectWarehouseForStockDecrease");
- $value = $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1);
+ $label = $object->type == 2 ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
+ $value = $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1);
}
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value));
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
+ // 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
+ // => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
- if ($object->type != 2 && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
+ if ($object->type != 2 && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
{
- $text.=' '.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive");
+ $text .= ' ' . img_warning() . ' ' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive");
}
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,(($object->type != 2 && $object->total_ttc < 0)?"no":"yes"),($conf->notification->enabled?0:2));
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != 2 && $object->total_ttc < 0) ? "no" : "yes"), ($conf->notification->enabled ? 0 : 2));
}
-
+
// Confirm back to draft status
- if ($action == 'modif')
- {
- $text=$langs->trans('ConfirmUnvalidateBill',$object->ref);
- $formquestion=array();
-
- $qualified_for_stock_change=0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(2);
+ if ($action == 'modif') {
+ $text = $langs->trans('ConfirmUnvalidateBill', $object->ref);
+ $formquestion = array();
+
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
}
- else
- {
- $qualified_for_stock_change=$object->hasProductsOrServices(1);
- }
- if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
- {
+ if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) {
$langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
- $formproduct=new FormProduct($db);
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
+ $formproduct = new FormProduct($db);
$warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) {
- $label = $object->type==2?$langs->trans("WarehouseForStockDecrease", current($warehouse_array)):$langs->trans("WarehouseForStockIncrease", current($warehouse_array));
+ $label = $object->type == 2 ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
$value = ' ';
} else {
- $label=$object->type==2?$langs->trans("SelectWarehouseForStockDecrease"):$langs->trans("SelectWarehouseForStockIncrease");
- $value = $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1);
+ $label = $object->type == 2 ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $value = $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1);
}
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value));
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
+ // 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
+ // => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
-
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('UnvalidateBill'),$text,'confirm_modif',$formquestion,"yes",1);
+
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('UnvalidateBill'), $text, 'confirm_modif', $formquestion, "yes", 1);
}
-
+
// Confirmation du classement paye
- if ($action == 'paid' && $resteapayer <= 0)
- {
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidBill',$object->ref),'confirm_paid','',"yes",1);
+ if ($action == 'paid' && $resteapayer <= 0) {
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1);
}
- if ($action == 'paid' && $resteapayer > 0)
- {
+ if ($action == 'paid' && $resteapayer > 0) {
// Code
- $i=0;
- $close[$i]['code']='discount_vat';$i++;
- $close[$i]['code']='badcustomer';$i++;
+ $i = 0;
+ $close [$i] ['code'] = 'discount_vat';
+ $i ++;
+ $close [$i] ['code'] = 'badcustomer';
+ $i ++;
// Help
- $i=0;
- $close[$i]['label']=$langs->trans("HelpEscompte").' '.$langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");$i++;
- $close[$i]['label']=$langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");$i++;
+ $i = 0;
+ $close [$i] ['label'] = $langs->trans("HelpEscompte") . ' ' . $langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
+ $i ++;
+ $close [$i] ['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
+ $i ++;
// Texte
- $i=0;
- $close[$i]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscountVat",$resteapayer,$langs->trans("Currency".$conf->currency)),$close[$i]['label'],1);$i++;
- $close[$i]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer",$resteapayer,$langs->trans("Currency".$conf->currency)),$close[$i]['label'],1);$i++;
+ $i = 0;
+ $close [$i] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscountVat", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close [$i] ['label'], 1);
+ $i ++;
+ $close [$i] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close [$i] ['label'], 1);
+ $i ++;
// arrayreasons[code]=reason
- foreach($close as $key => $val)
- {
- $arrayreasons[$close[$key]['code']]=$close[$key]['reason'];
+ foreach ($close as $key => $val) {
+ $arrayreasons [$close [$key] ['code']] = $close [$key] ['reason'];
}
-
+
// Cree un tableau formulaire
- $formquestion=array(
- 'text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"),
- array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons),
- array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100')
- );
+ $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','size' => '100'));
// Paiement incomplet. On demande si motif = escompte ou autre
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidPartially',$object->ref),'confirm_paid_partially',$formquestion,"yes");
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes");
}
-
+
// Confirmation du classement abandonne
- if ($action == 'canceled')
- {
+ if ($action == 'canceled') {
// S'il y a une facture de remplacement pas encore validee (etat brouillon),
// on ne permet pas de classer abandonner la facture.
- if ($objectidnext)
- {
- $facturereplacement=new Facture($db);
+ if ($objectidnext) {
+ $facturereplacement = new Facture($db);
$facturereplacement->fetch($objectidnext);
- $statusreplacement=$facturereplacement->statut;
+ $statusreplacement = $facturereplacement->statut;
}
- if ($objectidnext && $statusreplacement == 0)
- {
- print ''.$langs->trans("ErrorCantCancelIfReplacementInvoiceNotValidated").'
';
- }
- else
- {
+ if ($objectidnext && $statusreplacement == 0) {
+ print '' . $langs->trans("ErrorCantCancelIfReplacementInvoiceNotValidated") . '
';
+ } else {
// Code
- $close[1]['code']='badcustomer';
- $close[2]['code']='abandon';
+ $close [1] ['code'] = 'badcustomer';
+ $close [2] ['code'] = 'abandon';
// Help
- $close[1]['label']=$langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
- $close[2]['label']=$langs->trans("ConfirmClassifyAbandonReasonOtherDesc");
+ $close [1] ['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
+ $close [2] ['label'] = $langs->trans("ConfirmClassifyAbandonReasonOtherDesc");
// Texte
- $close[1]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer",$object->ref),$close[1]['label'],1);
- $close[2]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyAbandonReasonOther"),$close[2]['label'],1);
+ $close [1] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $object->ref), $close [1] ['label'], 1);
+ $close [2] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyAbandonReasonOther"), $close [2] ['label'], 1);
// arrayreasons
- $arrayreasons[$close[1]['code']]=$close[1]['reason'];
- $arrayreasons[$close[2]['code']]=$close[2]['reason'];
-
+ $arrayreasons [$close [1] ['code']] = $close [1] ['reason'];
+ $arrayreasons [$close [2] ['code']] = $close [2] ['reason'];
+
// Cree un tableau formulaire
- $formquestion=array(
- 'text' => $langs->trans("ConfirmCancelBillQuestion"),
- array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons),
- array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100')
- );
-
- $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$object->ref),'confirm_canceled',$formquestion,"yes");
+ $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','size' => '100'));
+
+ $formconfirm = $form->formconfirm($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes");
}
}
-
+
// Confirmation de la suppression d'une ligne produit
- if ($action == 'ask_deleteline')
- {
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
+ if ($action == 'ask_deleteline') {
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
}
-
+
// Clone confirmation
- if ($action == 'clone')
- {
+ if ($action == 'clone') {
// Create an array for form
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
- array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company('','socid','(s.client=1 OR s.client=2 OR s.client=3)',1))
- );
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
+ array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company('', 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)));
// Paiement incomplet. On demande si motif = escompte ou autre
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',1);
+ $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
-
- if (! $formconfirm)
- {
- $parameters=array('lineid'=>$lineid);
- $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+
+ if (! $formconfirm) {
+ $parameters = array('lineid' => $lineid);
+ $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by
+ // hook
}
-
+
// Print form confirm
print $formconfirm;
-
-
-
-
+
// Invoice content
-
+
print '';
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
+
+ $linkback = '' . $langs->trans("BackToList") . ' ';
+
// Ref
- print ''.$langs->trans('Ref').' ';
+ print '' . $langs->trans('Ref') . ' ';
print '';
- $morehtmlref='';
- $discount=new DiscountAbsolute($db);
- $result=$discount->fetch(0,$object->id);
- if ($result > 0)
- {
- $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
+ $morehtmlref = '';
+ $discount = new DiscountAbsolute($db);
+ $result = $discount->fetch(0, $object->id);
+ if ($result > 0) {
+ $morehtmlref = ' (' . $langs->trans("CreditNoteConvertedIntoDiscount", $discount->getNomUrl(1, 'discount')) . ')';
}
- if ($result < 0)
- {
- dol_print_error('',$discount->error);
+ if ($result < 0) {
+ dol_print_error('', $discount->error);
}
print $form->showrefnav($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref);
print ' ';
-
+
// Ref customer
print '';
print '';
print ' ';
print '';
- if ($user->rights->facture->creer && $action == 'refclient')
- {
- print '';
- }
- else
- {
+ } else {
print $object->ref_client;
}
print ' ';
-
+
// Third party
print '';
print '';
print ' ';
- if ($action == 'editthirdparty')
- {
- $form->form_thirdparty($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,'socid');
- }
- else
- {
- print ' '.$soc->getNomUrl(1,'compta');
+ if ($action == 'editthirdparty') {
+ $form->form_thirdparty($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->socid, 'socid');
+ } else {
+ print ' ' . $soc->getNomUrl(1, 'compta');
print ' ';
- print '('.$langs->trans('OtherBills').' ';
+ print '(' . $langs->trans('OtherBills') . ' ';
// Outstanding Bill
- $outstandigBills=$soc->get_OutstandingBill();
- print ' - '.$langs->trans('CurrentOutstandingBill').': ';
- print price($outstandigBills,'',$langs,0,0,-1,$conf->currency);
- if ($soc->outstanding_limit != '')
- {
- if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
- print ' / '.price($soc->outstanding_limit);
+ $outstandigBills = $soc->get_OutstandingBill();
+ print ' - ' . $langs->trans('CurrentOutstandingBill') . ': ';
+ print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency);
+ if ($soc->outstanding_limit != '') {
+ if ($outstandigBills > $soc->outstanding_limit)
+ print img_warning($langs->trans("OutstandingBillReached"));
+ print ' / ' . price($soc->outstanding_limit);
}
print ')';
}
print ' ';
-
+
// Type
- print ''.$langs->trans('Type').' ';
+ print ' ' . $langs->trans('Type') . ' ';
print $object->getLibType();
- if ($object->type == 1)
- {
- $facreplaced=new Facture($db);
+ if ($object->type == 1) {
+ $facreplaced = new Facture($db);
$facreplaced->fetch($object->fk_facture_source);
- print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
+ print ' (' . $langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)) . ')';
}
- if ($object->type == 2)
- {
- $facusing=new Facture($db);
+ if ($object->type == 2) {
+ $facusing = new Facture($db);
$facusing->fetch($object->fk_facture_source);
- print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
+ print ' (' . $langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)) . ')';
}
-
- $facidavoir=$object->getListIdAvoirFromInvoice();
- if (count($facidavoir) > 0)
- {
- print ' ('.$langs->transnoentities("InvoiceHasAvoir");
- $i=0;
- foreach($facidavoir as $id)
- {
- if ($i==0) print ' ';
- else print ',';
- $facavoir=new Facture($db);
+
+ $facidavoir = $object->getListIdAvoirFromInvoice();
+ if (count($facidavoir) > 0) {
+ print ' (' . $langs->transnoentities("InvoiceHasAvoir");
+ $i = 0;
+ foreach ($facidavoir as $id) {
+ if ($i == 0)
+ print ' ';
+ else
+ print ',';
+ $facavoir = new Facture($db);
$facavoir->fetch($id);
print $facavoir->getNomUrl(1);
}
print ')';
}
- if ($objectidnext > 0)
- {
- $facthatreplace=new Facture($db);
+ if ($objectidnext > 0) {
+ $facthatreplace = new Facture($db);
$facthatreplace->fetch($objectidnext);
- print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
+ print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')';
}
print ' ';
-
+
// Relative and absolute discounts
- $addrelativediscount='id.'">'.$langs->trans("EditRelativeDiscounts").' ';
- $addabsolutediscount='id.'">'.$langs->trans("EditGlobalDiscounts").' ';
- $addcreditnote='id.'">'.$langs->trans("AddCreditNote").' ';
-
- print ''.$langs->trans('Discounts');
+ $addrelativediscount = 'id . '">' . $langs->trans("EditRelativeDiscounts") . ' ';
+ $addabsolutediscount = 'id . '">' . $langs->trans("EditGlobalDiscounts") . ' ';
+ $addcreditnote = 'id . '">' . $langs->trans("AddCreditNote") . ' ';
+
+ print ' ' . $langs->trans('Discounts');
print ' ';
- if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
- else print $langs->trans("CompanyHasNoRelativeDiscount");
- //print ' ('.$addrelativediscount.')';
-
- if ($absolute_discount > 0)
- {
+ if ($soc->remise_percent)
+ print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
+ else
+ print $langs->trans("CompanyHasNoRelativeDiscount");
+ // print ' ('.$addrelativediscount.')';
+
+ if ($absolute_discount > 0) {
print '. ';
- if ($object->statut > 0 || $object->type == 2 || $object->type == 3)
- {
- if ($object->statut == 0)
- {
- print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
+ if ($object->statut > 0 || $object->type == 2 || $object->type == 3) {
+ if ($object->statut == 0) {
+ print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
print '. ';
- }
- else
- {
- if ($object->statut < 1 || $object->type == 2 || $object->type == 3)
- {
- $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
- print ' '.$text.'. ';
- }
- else
- {
- $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
- $text2=$langs->trans("AbsoluteDiscountUse");
- print $form->textwithpicto($text,$text2);
+ } else {
+ if ($object->statut < 1 || $object->type == 2 || $object->type == 3) {
+ $text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
+ print ' ' . $text . '. ';
+ } else {
+ $text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
+ $text2 = $langs->trans("AbsoluteDiscountUse");
+ print $form->textwithpicto($text, $text2);
}
}
- }
- else
- {
+ } else {
// Remise dispo de type remise fixe (not credit note)
print ' ';
- $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' ('.$addabsolutediscount.')');
+ $form->form_remise_dispo($_SERVER ["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')');
}
- }
- else
- {
- if ($absolute_creditnote > 0) // If not, link will be added later
+ } else {
+ if ($absolute_creditnote > 0) // If not, link will be added later
{
- if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.') ';
- else print '. ';
- }
- else print '. ';
- }
- if ($absolute_creditnote > 0)
- {
- // If validated, we show link "add credit note to payment"
- if ($object->statut != 1 || $object->type == 2 || $object->type == 3)
- {
- if ($object->statut == 0 && $object->type != 3)
- {
- $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
- print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
- }
+ if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
+ print ' (' . $addabsolutediscount . ') ';
else
- {
- print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'.';
+ print '. ';
+ } else
+ print '. ';
+ }
+ if ($absolute_creditnote > 0) {
+ // If validated, we show link "add credit note to payment"
+ if ($object->statut != 1 || $object->type == 2 || $object->type == 3) {
+ if ($object->statut == 0 && $object->type != 3) {
+ $text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
+ print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
+ } else {
+ print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
}
- }
- else
- {
+ } else {
// Remise dispo de type avoir
- if (! $absolute_discount) print ' ';
- //$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, 0); // We must allow credit not even if amount is higher
+ if (! $absolute_discount)
+ print ' ';
+ // $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, 0); // We
+ // must
+ // allow
+ // credit
+ // not
+ // even
+ // if
+ // amount
+ // is
+ // higher
}
}
- if (! $absolute_discount && ! $absolute_creditnote)
- {
+ if (! $absolute_discount && ! $absolute_creditnote) {
print $langs->trans("CompanyHasNoAbsoluteDiscount");
- if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.') ';
- else print '. ';
+ if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
+ print ' (' . $addabsolutediscount . ') ';
+ else
+ print '. ';
}
- //if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
+ // if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
// {
- //if (! $absolute_discount && ! $absolute_creditnote) print ' ';
- //print ' - ';
- //print $addabsolutediscount;
- //print ' - '.$addcreditnote; // We disbale link to credit note
- //}
+ // if (! $absolute_discount && ! $absolute_creditnote) print ' ';
+ // print ' - ';
+ // print $addabsolutediscount;
+ // print ' - '.$addcreditnote; // We disbale link to credit note
+ // }
print ' ';
-
+
// Date invoice
print '';
print '';
print ' ';
-
- if ($object->type != 2)
- {
- if ($action == 'editinvoicedate')
- {
- $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate');
+
+ if ($object->type != 2) {
+ if ($action == 'editinvoicedate') {
+ $form->form_date($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate');
+ } else {
+ print dol_print_date($object->date, 'daytext');
}
- else
- {
- print dol_print_date($object->date,'daytext');
- }
- }
- else
- {
- print dol_print_date($object->date,'daytext');
+ } else {
+ print dol_print_date($object->date, 'daytext');
}
print ' ';
-
-
+
// List of payments
-
- $sign=1;
- if ($object->type == 2) $sign=-1;
-
- $nbrows=8; $nbcols=2;
- if (! empty($conf->projet->enabled)) $nbrows++;
- if (! empty($conf->banque->enabled)) $nbcols++;
- //if (! empty($soc->outstandingbill)) $nbrows++;
- if($mysoc->localtax1_assuj=="1") $nbrows++;
- if($mysoc->localtax2_assuj=="1") $nbrows++;
- if ($selleruserevenustamp) $nbrows++;
-
- print '';
-
+
+ $sign = 1;
+ if ($object->type == 2)
+ $sign = - 1;
+
+ $nbrows = 8;
+ $nbcols = 2;
+ if (! empty($conf->projet->enabled))
+ $nbrows ++;
+ if (! empty($conf->banque->enabled))
+ $nbcols ++;
+ // if (! empty($soc->outstandingbill)) $nbrows++;
+ if ($mysoc->localtax1_assuj == "1")
+ $nbrows ++;
+ if ($mysoc->localtax2_assuj == "1")
+ $nbrows ++;
+ if ($selleruserevenustamp)
+ $nbrows ++;
+
+ print ' ';
+
print '';
-
+
// List of payments already done
print '';
- print ''.($object->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).' ';
- print ''.$langs->trans('Type').' ';
- if (! empty($conf->banque->enabled)) print ''.$langs->trans('BankAccount').' ';
- print ''.$langs->trans('Amount').' ';
+ print '' . ($object->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . ' ';
+ print '' . $langs->trans('Type') . ' ';
+ if (! empty($conf->banque->enabled))
+ print '' . $langs->trans('BankAccount') . ' ';
+ print '' . $langs->trans('Amount') . ' ';
print ' ';
print ' ';
-
- $var=true;
-
+
+ $var = true;
+
// Payments already done (from payment on this invoice)
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
- $sql.= ' c.code as payment_code, c.libelle as payment_label,';
- $sql.= ' pf.amount,';
- $sql.= ' ba.rowid as baid, ba.ref, ba.label';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
- $sql.= ' WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
- $sql.= ' ORDER BY p.datep, p.tms';
-
+ $sql .= ' c.code as payment_code, c.libelle as payment_label,';
+ $sql .= ' pf.amount,';
+ $sql .= ' ba.rowid as baid, ba.ref, ba.label';
+ $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p';
+ $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
+ $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
+ $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
+ $sql .= ' ORDER BY p.datep, p.tms';
+
$result = $db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $db->num_rows($result);
$i = 0;
-
- //if ($object->type != 2)
- //{
- if ($num > 0)
- {
- while ($i < $num)
- {
+
+ // if ($object->type != 2)
+ // {
+ if ($num > 0) {
+ while ($i < $num) {
$objp = $db->fetch_object($result);
- $var=!$var;
- print '';
- print ''.img_object($langs->trans('ShowPayment'),'payment').' ';
- print dol_print_date($db->jdate($objp->dp),'day').' ';
- $label=($langs->trans("PaymentType".$objp->payment_code)!=("PaymentType".$objp->payment_code))?$langs->trans("PaymentType".$objp->payment_code):$objp->payment_label;
- print ''.$label.' '.$objp->num_paiement.' ';
- if (! empty($conf->banque->enabled))
- {
- $bankaccountstatic->id=$objp->baid;
- $bankaccountstatic->ref=$objp->ref;
- $bankaccountstatic->label=$objp->ref;
+ $var = ! $var;
+ print '';
+ print '' . img_object($langs->trans('ShowPayment'), 'payment') . ' ';
+ print dol_print_date($db->jdate($objp->dp), 'day') . ' ';
+ $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label;
+ print '' . $label . ' ' . $objp->num_paiement . ' ';
+ if (! empty($conf->banque->enabled)) {
+ $bankaccountstatic->id = $objp->baid;
+ $bankaccountstatic->ref = $objp->ref;
+ $bankaccountstatic->label = $objp->ref;
print '';
- if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1,'transactions');
+ if ($bankaccountstatic->id)
+ print $bankaccountstatic->getNomUrl(1, 'transactions');
print ' ';
}
- print ''.price($sign * $objp->amount).' ';
+ print '' . price($sign * $objp->amount) . ' ';
print ' ';
print ' ';
- $i++;
+ $i ++;
}
+ } else {
+ print '' . $langs->trans("None") . ' ';
}
- else
- {
- print ''.$langs->trans("None").' ';
- }
- //}
+ // }
$db->free($result);
- }
- else
- {
+ } else {
dol_print_error($db);
}
-
- if ($object->type != 2)
- {
+
+ if ($object->type != 2) {
// Total already paid
- print '';
- if ($object->type != 3) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
- else print $langs->trans('AlreadyPaid');
- print ' : '.price($totalpaye).' ';
-
- $resteapayeraffiche=$resteapayer;
-
+ print '';
+ if ($object->type != 3)
+ print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
+ else
+ print $langs->trans('AlreadyPaid');
+ print ' : ' . price($totalpaye) . ' ';
+
+ $resteapayeraffiche = $resteapayer;
+
// Loop on each credit note or deposit amount applied
- $creditnoteamount=0;
- $depositamount=0;
+ $creditnoteamount = 0;
+ $depositamount = 0;
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
- $sql.= " re.description, re.fk_facture_source";
- $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
- $sql.= " WHERE fk_facture = ".$object->id;
- $resql=$db->query($sql);
- if ($resql)
- {
+ $sql .= " re.description, re.fk_facture_source";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
+ $sql .= " WHERE fk_facture = " . $object->id;
+ $resql = $db->query($sql);
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- $invoice=new Facture($db);
- while ($i < $num)
- {
+ $invoice = new Facture($db);
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$invoice->fetch($obj->fk_facture_source);
- print '';
- if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
- if ($invoice->type == 3) print $langs->trans("Deposit").' ';
+ print ' ';
+ if ($invoice->type == 2)
+ print $langs->trans("CreditNote") . ' ';
+ if ($invoice->type == 3)
+ print $langs->trans("Deposit") . ' ';
print $invoice->getNomUrl(0);
print ' : ';
- print ''.price($obj->amount_ttc).' ';
+ print '' . price($obj->amount_ttc) . ' ';
print '';
- print 'id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().' ';
+ print 'id . '&action=unlinkdiscount&discountid=' . $obj->rowid . '">' . img_delete() . ' ';
print ' ';
- $i++;
- if ($invoice->type == 2) $creditnoteamount += $obj->amount_ttc;
- if ($invoice->type == 3) $depositamount += $obj->amount_ttc;
+ $i ++;
+ if ($invoice->type == 2)
+ $creditnoteamount += $obj->amount_ttc;
+ if ($invoice->type == 3)
+ $depositamount += $obj->amount_ttc;
}
- }
- else
- {
+ } else {
dol_print_error($db);
}
-
+
// Paye partiellement 'escompte'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat')
- {
- print '';
- print $form->textwithpicto($langs->trans("Discount").':',$langs->trans("HelpEscompte"),-1);
- print ' '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' ';
- $resteapayeraffiche=0;
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat') {
+ print '';
+ print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1);
+ print ' ' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' ';
+ $resteapayeraffiche = 0;
}
// Paye partiellement ou Abandon 'badcustomer'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer')
- {
- print '';
- print $form->textwithpicto($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
- print ' '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' ';
- //$resteapayeraffiche=0;
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer') {
+ print '';
+ print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1);
+ print ' ' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' ';
+ // $resteapayeraffiche=0;
}
// Paye partiellement ou Abandon 'product_returned'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned')
- {
- print '';
- print $form->textwithpicto($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
- print ' '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' ';
- $resteapayeraffiche=0;
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned') {
+ print '';
+ print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1);
+ print ' ' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' ';
+ $resteapayeraffiche = 0;
}
// Paye partiellement ou Abandon 'abandon'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon')
- {
- print '';
- $text=$langs->trans("HelpAbandonOther");
- if ($object->close_note) $text.=''.$langs->trans("Reason").' :'.$object->close_note;
- print $form->textwithpicto($langs->trans("Abandoned").':',$text,-1);
- print ' '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' ';
- $resteapayeraffiche=0;
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon') {
+ print '';
+ $text = $langs->trans("HelpAbandonOther");
+ if ($object->close_note)
+ $text .= '' . $langs->trans("Reason") . ' :' . $object->close_note;
+ print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1);
+ print ' ' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' ';
+ $resteapayeraffiche = 0;
}
-
+
// Billed
- print ''.$langs->trans("Billed").' : '.price($object->total_ttc).' ';
-
+ print '' . $langs->trans("Billed") . ' : ' . price($object->total_ttc) . ' ';
+
// Remainder to pay
- print '';
- if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
- else print $langs->trans('ExcessReceived');
+ print ' ';
+ if ($resteapayeraffiche >= 0)
+ print $langs->trans('RemainderToPay');
+ else
+ print $langs->trans('ExcessReceived');
print ' : ';
- print ''.price($resteapayeraffiche).' ';
+ print '' . price($resteapayeraffiche) . ' ';
print ' ';
- }
- else // Credit note
+ } else // Credit note
{
// Total already paid back
- print '';
+ print ' ';
print $langs->trans('AlreadyPaidBack');
- print ' : '.price($sign * $totalpaye).' ';
-
+ print ' :' . price($sign * $totalpaye) . ' ';
+
// Billed
- print ''.$langs->trans("Billed").' : '.price($sign * $object->total_ttc).' ';
-
+ print '' . $langs->trans("Billed") . ' : ' . price($sign * $object->total_ttc) . ' ';
+
// Remainder to pay back
- print '';
- if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack');
- else print $langs->trans('ExcessPaydBack');
+ print ' ';
+ if ($resteapayeraffiche <= 0)
+ print $langs->trans('RemainderToPayBack');
+ else
+ print $langs->trans('ExcessPaydBack');
print ' : ';
- print ''.price($sign * $resteapayeraffiche).' ';
+ print '' . price($sign * $resteapayeraffiche) . ' ';
print ' ';
-
+
// Sold credit note
- //print ''.$langs->trans('TotalTTC').' : ';
- //print ''.price($sign * $object->total_ttc).' ';
+ // print ''.$langs->trans('TotalTTC').' : ';
+ // print ''.price($sign *
+ // $object->total_ttc).' ';
}
-
+
print '
';
-
+
// Margin Infos
- if (! empty($conf->margin->enabled))
- {
+ if (! empty($conf->margin->enabled)) {
print ' ';
$object->displayMarginInfos($object->statut > 0);
}
-
+
print ' ';
-
+
// Conditions de reglement
print '';
print '';
print ' ';
- if ($object->type != 2)
- {
- if ($action == 'editconditions')
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
+ if ($object->type != 2) {
+ if ($action == 'editconditions') {
+ $form->form_conditions_reglement($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id');
+ } else {
+ $form->form_conditions_reglement($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none');
}
- else
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
- }
- }
- else
- {
+ } else {
print ' ';
}
print ' ';
-
+
// Date payment term
print '';
print '';
print ' ';
- if ($object->type != 2)
- {
- if ($action == 'editpaymentterm')
- {
- $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm');
+ if ($object->type != 2) {
+ if ($action == 'editpaymentterm') {
+ $form->form_date($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm');
+ } else {
+ print dol_print_date($object->date_lim_reglement, 'daytext');
+ if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am))
+ print img_warning($langs->trans('Late'));
}
- else
- {
- print dol_print_date($object->date_lim_reglement,'daytext');
- if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am)) print img_warning($langs->trans('Late'));
- }
- }
- else
- {
+ } else {
print ' ';
}
print ' ';
-
+
// Payment mode
print '';
print '';
print ' ';
- if ($action == 'editmode')
- {
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
- }
- else
- {
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none');
+ if ($action == 'editmode') {
+ $form->form_modes_reglement($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
+ } else {
+ $form->form_modes_reglement($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->mode_reglement_id, 'none');
}
print ' ';
-
+
// Amount
- print ''.$langs->trans('AmountHT').' ';
- print ''.price($object->total_ht,1,'',1,-1,-1,$conf->currency).' ';
- print ''.$langs->trans('AmountVAT').' '.price($object->total_tva,1,'',1,-1,-1,$conf->currency).' ';
+ print '' . $langs->trans('AmountHT') . ' ';
+ print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ' ';
+ print '' . $langs->trans('AmountVAT') . ' ' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ' ';
print '';
-
+
// Amount Local Taxes
- if ($mysoc->localtax1_assuj=="1" && $mysoc->useLocalTax(1)) //Localtax1 (example RE)
+ if ($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) // Localtax1 (example RE)
{
- print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).' ';
- print ''.price($object->total_localtax1,1,'',1,-1,-1,$conf->currency).' ';
+ print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ' ';
+ print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ' ';
}
- if ($mysoc->localtax2_assuj=="1" && $mysoc->useLocalTax(2)) //Localtax2 (example IRPF)
+ if ($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) // Localtax2 (example IRPF)
{
- print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).' ';
- print ''.price($object->total_localtax2,1,'',1,-1,-1,$conf->currency).' ';
+ print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' ';
+ print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ' ';
}
-
+
// Revenue stamp
- if ($selleruserevenustamp) // Test company use revenue stamp
+ if ($selleruserevenustamp) // Test company use revenue stamp
{
print '';
print '';
print ' ';
- if ($action == 'editrevenuestamp')
- {
- print '';
- }
- else
- {
- print price($object->revenuestamp,1,'',1,-1,-1,$conf->currency);
+ } else {
+ print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
}
print ' ';
}
-
+
// Total with tax
- print ''.$langs->trans('AmountTTC').' '.price($object->total_ttc,1,'',1,-1,-1,$conf->currency).' ';
-
+ print '' . $langs->trans('AmountTTC') . ' ' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ' ';
+
// Statut
- print ''.$langs->trans('Status').' ';
- print ''.($object->getLibStatut(4,$totalpaye)).' ';
-
+ print '' . $langs->trans('Status') . ' ';
+ print '' . ($object->getLibStatut(4, $totalpaye)) . ' ';
+
// Project
- if (! empty($conf->projet->enabled))
- {
+ if (! empty($conf->projet->enabled)) {
$langs->load('projects');
print '';
print '';
-
+
print '';
-
+
print ' ';
- if ($action == 'classify')
- {
- $form->form_project($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,$object->fk_project,'projectid');
- }
- else
- {
- $form->form_project($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,$object->fk_project,'none');
+ if ($action == 'classify') {
+ $form->form_project($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid');
+ } else {
+ $form->form_project($_SERVER ['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none');
}
print ' ';
print ' ';
}
-
+
// Other attributes (TODO Move this into an include)
- $res=$object->fetch_optionals($object->id,$extralabels);
- $parameters=array('colspan' => ' colspan="2"');
- $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
- if (empty($reshook) && ! empty($extrafields->attribute_label))
- {
-
- foreach($extrafields->attribute_label as $key=>$label)
- {
+ $res = $object->fetch_optionals($object->id, $extralabels);
+ $parameters = array('colspan' => ' colspan="2"');
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
+ // hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label)) {
+
+ foreach ($extrafields->attribute_label as $key => $label) {
if ($action == 'edit_extras') {
- $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
+ $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
} else {
- $value=$object->array_options["options_".$key];
+ $value = $object->array_options ["options_" . $key];
}
- if ($extrafields->attribute_type[$key] == 'separate')
- {
+ if ($extrafields->attribute_type [$key] == 'separate') {
print $extrafields->showSeparator($key);
- }
- else
- {
+ } else {
print 'attribute_required[$key])) print ' class="fieldrequired"';
- print '>'.$label.' ';
+ if (! empty($extrafields->attribute_required [$key]))
+ print ' class="fieldrequired"';
+ print '>' . $label . ' ';
// Convert date into timestamp format
- if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
- {
- $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
+ if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
+ $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
-
- if ($action == 'edit_extras' && $user->rights->facture->creer && GETPOST('attribute') == $key)
- {
- print '';
+ } else {
+ print $extrafields->showOutputField($key, $value);
+ if ($object->statut == 0 && $user->rights->facture->creer)
+ print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ' ';
}
- else
- {
- print $extrafields->showOutputField($key,$value);
- if ($object->statut == 0 && $user->rights->facture->creer) print ''.img_picto('','edit').' '.$langs->trans('Modify').' ';
- }
- print ' '."\n";
+ print '' . "\n";
}
}
}
-
+
print '
';
-
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
- {
+
+ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
+ include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php';
}
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$blocname = 'notes';
$title = $langs->trans('Notes');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
+ include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php';
}
-
+
// Lines
$result = $object->getLinesArray();
-
-
- print ' \n";
-
+
dol_fiche_end();
-
-
+
// Boutons actions
-
- if ($action != 'prerelance' && $action != 'presend' && $action != 'valid' && $action != 'editline')
- {
+
+ if ($action != 'prerelance' && $action != 'presend' && $action != 'valid' && $action != 'editline') {
print '';
-
- $parameters=array();
- $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
- if (empty($reshook))
- {
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
+ // modified by hook
+ if (empty($reshook)) {
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
- if ($object->statut == 1)
- {
+ if ($object->statut == 1) {
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
$ventilExportCompta = $object->getVentilExportCompta();
-
- if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
- {
- if (! $objectidnext)
- {
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)
- {
- print '
';
+
+ if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
+ if (! $objectidnext) {
+ if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate) {
+ print '
';
+ } else {
+ print '
' . $langs->trans('Modify') . '
';
}
- else
- {
- print '
'.$langs->trans('Modify').'
';
- }
- }
- else
- {
- print '
'.$langs->trans('Modify').'
';
+ } else {
+ print '
' . $langs->trans('Modify') . '
';
}
}
}
-
+
// Reopen a standard paid invoice
- if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3) && $user->rights->facture->creer) // A paid invoice (partially or completely)
+ if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3) && $user->rights->facture->creer) // A paid
+ // invoice
+ // (partially or
+ // completely)
{
- if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
+ if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{
- print '
';
- }
- else
- {
- print '
'.$langs->trans('ReOpen').'
';
+ print '
';
+ } else {
+ print '
' . $langs->trans('ReOpen') . '
';
}
}
-
+
// Validate
- if ($object->statut == 0 && count($object->lines) > 0 &&
- (
- (($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0))
- || ($object->type == 2 && $object->total_ttc <= 0))
- )
- {
- if ($user->rights->facture->valider)
- {
- print '
';
+ if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == 2 && $object->total_ttc <= 0))) {
+ if ($user->rights->facture->valider) {
+ print '
';
}
}
-
+
// Send by mail
- if (($object->statut == 1 || $object->statut == 2))
- {
- if ($objectidnext)
- {
- print '
'.$langs->trans('SendByMail').'
';
- }
- else
- {
- if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send)
- {
- print '
';
- }
- else print '
';
+ if (($object->statut == 1 || $object->statut == 2)) {
+ if ($objectidnext) {
+ print '
' . $langs->trans('SendByMail') . '
';
+ } else {
+ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send) {
+ print '
';
+ } else
+ print '
';
}
}
-
- if (! empty($conf->global->FACTURE_SHOW_SEND_REMINDER)) // For backward compatibility
+
+ if (! empty($conf->global->FACTURE_SHOW_SEND_REMINDER)) // For backward compatibility
{
- if (($object->statut == 1 || $object->statut == 2) && $resteapayer > 0)
- {
- if ($objectidnext)
- {
- print '
'.$langs->trans('SendRemindByMail').'
';
- }
- else
- {
- if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send)
- {
- print '
';
- }
- else print '
';
+ if (($object->statut == 1 || $object->statut == 2) && $resteapayer > 0) {
+ if ($objectidnext) {
+ print '
' . $langs->trans('SendRemindByMail') . '
';
+ } else {
+ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send) {
+ print '
';
+ } else
+ print '
';
}
}
}
-
+
// Create payment
- if ($object->type != 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement)
- {
- if ($objectidnext)
- {
- print '
'.$langs->trans('DoPayment').'
';
- }
- else
- {
- if ($resteapayer == 0)
- {
- print '
'.$langs->trans('DoPayment').'
';
- }
- else
- {
- print '
';
+ if ($object->type != 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) {
+ if ($objectidnext) {
+ print '
' . $langs->trans('DoPayment') . '
';
+ } else {
+ if ($resteapayer == 0) {
+ print '
' . $langs->trans('DoPayment') . '
';
+ } else {
+ print '
';
}
}
}
-
+
// Reverse back money or convert to reduction
- if ($object->type == 2 || $object->type == 3)
- {
+ if ($object->type == 2 || $object->type == 3) {
// For credit note only
- if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement)
- {
- print '
';
+ if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) {
+ print '
';
}
// For credit note
- if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0)
- {
- print '
';
+ if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0) {
+ print '
';
}
// For deposit invoice
- if ($object->type == 3 && $object->statut == 1 && $resteapayer == 0 && $user->rights->facture->creer)
- {
- print '
';
+ if ($object->type == 3 && $object->statut == 1 && $resteapayer == 0 && $user->rights->facture->creer) {
+ print '
';
}
}
-
+
// Classify paid (if not deposit and not credit note. Such invoice are "converted")
- if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement &&
- (($object->type != 2 && $object->type != 3 && $resteapayer <= 0) || ($object->type == 2 && $resteapayer >= 0)) )
- {
- print '
';
+ if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != 2 && $object->type != 3 && $resteapayer <= 0) || ($object->type == 2 && $resteapayer >= 0))) {
+ print '
';
}
-
+
// Classify 'closed not completely paid' (possible si validee et pas encore classee payee)
- if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0
- && $user->rights->facture->paiement)
- {
- if ($totalpaye > 0 || $totalcreditnotes > 0)
- {
+ if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement) {
+ if ($totalpaye > 0 || $totalcreditnotes > 0) {
// If one payment or one credit note was linked to this invoice
- print '
';
- }
- else
- {
- if ($objectidnext)
- {
- print '
'.$langs->trans('ClassifyCanceled').'
';
- }
- else
- {
- print '
';
+ print '
';
+ } else {
+ if ($objectidnext) {
+ print '
' . $langs->trans('ClassifyCanceled') . '
';
+ } else {
+ print '
';
}
}
}
-
+
// Clone
- if (($object->type == 0 || $object->type == 3 || $object->type == 4) && $user->rights->facture->creer)
- {
- print '
';
+ if (($object->type == 0 || $object->type == 3 || $object->type == 4) && $user->rights->facture->creer) {
+ print '
';
}
-
+
// Clone as predefined
- if (($object->type == 0 || $object->type == 3 || $object->type == 4) && $object->statut == 0 && $user->rights->facture->creer)
- {
- if (! $objectidnext)
- {
- print '
';
+ if (($object->type == 0 || $object->type == 3 || $object->type == 4) && $object->statut == 0 && $user->rights->facture->creer) {
+ if (! $objectidnext) {
+ print '
';
}
}
-
+
// Delete
- if ($user->rights->facture->supprimer)
- {
- if (! $object->is_erasable())
- {
- print '
';
- }
- else if ($objectidnext)
- {
- print '
';
- }
- elseif ($object->getSommePaiement())
- {
- print '
';
- }
- else
- {
- print '
';
+ if ($user->rights->facture->supprimer) {
+ if (! $object->is_erasable()) {
+ print '
';
+ } else if ($objectidnext) {
+ print '
';
+ } elseif ($object->getSommePaiement()) {
+ print '
';
+ } else {
+ print '
';
}
+ } else {
+ print '
';
}
- else
- {
- print '
';
- }
-
+
print '
';
}
}
print ' ';
-
- if ($action != 'prerelance' && $action != 'presend')
- {
+
+ if ($action != 'prerelance' && $action != 'presend') {
print '';
print '
'; // ancre
-
+
// Documents generes
- $filename=dol_sanitizeFileName($object->ref);
- $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
- $urlsource=$_SERVER['PHP_SELF'].'?facid='.$object->id;
- $genallowed=$user->rights->facture->creer;
- $delallowed=$user->rights->facture->supprimer;
-
- print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
- $somethingshown=$formfile->numoffiles;
-
+ $filename = dol_sanitizeFileName($object->ref);
+ $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
+ $urlsource = $_SERVER ['PHP_SELF'] . '?facid=' . $object->id;
+ $genallowed = $user->rights->facture->creer;
+ $delallowed = $user->rights->facture->supprimer;
+
+ print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
+ $somethingshown = $formfile->numoffiles;
+
// Linked object block
- $somethingshown=$object->showLinkedObjectBlock();
-
- if (empty($somethingshown) && $object->statut > 0)
- {
- print '
'.$langs->trans('LinkedOrder').' ';
-
+ $somethingshown = $object->showLinkedObjectBlock();
+
+ if (empty($somethingshown) && $object->statut > 0) {
+ print '
' . $langs->trans('LinkedOrder') . ' ';
+
print '
';
-
+
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql.= ", ".MAIN_DB_PREFIX."commande as c";
- $sql.= ' WHERE c.fk_soc = '.$soc->id.'';
-
+ $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
+ $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
+ $sql .= ' WHERE c.fk_soc = ' . $soc->id . '';
+
$resqlorderlist = $db->query($sql);
- if ($resqlorderlist)
- {
+ if ($resqlorderlist) {
$num = $db->num_rows($resqlorderlist);
$i = 0;
-
+
print '
';
$db->free($resqlorderlist);
- }
- else
- {
+ } else {
dol_print_error($db);
}
-
+
print '
';
}
-
+
// Link for paypal payment
- if (! empty($conf->paypal->enabled) && $object->statut != 0)
- {
- include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
- print showPaypalPaymentUrl('invoice',$object->ref);
+ if (! empty($conf->paypal->enabled) && $object->statut != 0) {
+ include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
+ print showPaypalPaymentUrl('invoice', $object->ref);
}
-
+
print '
';
-
+
// List of actions on element
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- $formactions=new FormActions($db);
- $somethingshown=$formactions->showactions($object,'invoice',$socid);
-
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
+ $formactions = new FormActions($db);
+ $somethingshown = $formactions->showactions($object, 'invoice', $socid);
+
print '
';
- }
- else
- {
+ } else {
/*
* Affiche formulaire mail
*/
-
+
// By default if $action=='presend'
- $titreform='SendBillByMail';
- $topicmail='SendBillRef';
- $modelmail='facture_send';
-
- if ($action == 'prerelance') // For backward compatibility
+ $titreform = 'SendBillByMail';
+ $topicmail = 'SendBillRef';
+ $modelmail = 'facture_send';
+
+ if ($action == 'prerelance') // For backward compatibility
{
- $titrefrom='SendReminderBillByMail';
- $topicmail='SendReminderBillRef';
- $modelmail='facture_relance';
- $action='relance';
- }
- else $action='send';
-
+ $titrefrom = 'SendReminderBillByMail';
+ $topicmail = 'SendReminderBillRef';
+ $modelmail = 'facture_relance';
+ $action = 'relance';
+ } else
+ $action = 'send';
+
$ref = dol_sanitizeFileName($object->ref);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref,'/'));
- $file=$fileparams['fullname'];
-
+ include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
+ $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
+ $file = $fileparams ['fullname'];
+
// Build document if it not exists
- if (! $file || ! is_readable($file))
- {
+ if (! $file || ! is_readable($file)) {
// Define output language
$outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST ['lang_id']))
+ $newlang = $_REQUEST ['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang))
+ $newlang = $object->client->default_lang;
+ if (! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
-
- $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- if ($result <= 0)
- {
- dol_print_error($db,$result);
- exit;
+
+ $result = facture_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ if ($result <= 0) {
+ dol_print_error($db, $result);
+ exit();
}
- $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref,'/'));
- $file=$fileparams['fullname'];
+ $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
+ $file = $fileparams ['fullname'];
}
-
+
print ' ';
print_titre($langs->trans($titreform));
-
+
// Cree l'objet formulaire mail
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->fromtype = 'user';
- $formmail->fromid = $user->id;
+ $formmail->fromid = $user->id;
$formmail->fromname = $user->getFullName($langs);
$formmail->frommail = $user->email;
- $formmail->withfrom=1;
- $liste=array();
- foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value)
- {
- $liste[$key]=$value;
+ $formmail->withfrom = 1;
+ $liste = array();
+ foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
+ $liste [$key] = $value;
}
- $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; // List suggested for send to
- $formmail->withtocc=$liste; // List suggested for CC
- $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
- if(empty($object->ref_client))
- {
- $formmail->withtopic=$langs->transnoentities($topicmail,'__FACREF__');
+ $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; // List suggested for send to
+ $formmail->withtocc = $liste; // List suggested for CC
+ $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
+ if (empty($object->ref_client)) {
+ $formmail->withtopic = $langs->transnoentities($topicmail, '__FACREF__');
+ } else if (! empty($object->ref_client)) {
+ $formmail->withtopic = $langs->transnoentities($topicmail, '__FACREF__(__REFCLIENT__)');
}
- else if(!empty($object->ref_client))
- {
- $formmail->withtopic=$langs->transnoentities($topicmail,'__FACREF__(__REFCLIENT__)');
- }
- $formmail->withfile=2;
- $formmail->withbody=1;
- $formmail->withdeliveryreceipt=1;
- $formmail->withcancel=1;
+ $formmail->withfile = 2;
+ $formmail->withbody = 1;
+ $formmail->withdeliveryreceipt = 1;
+ $formmail->withcancel = 1;
// Tableau des substitutions
- $formmail->substit['__FACREF__']=$object->ref;
- $formmail->substit['__SIGNATURE__']=$user->signature;
- $formmail->substit['__REFCLIENT__']=$object->ref_client;
- $formmail->substit['__PERSONALIZED__']='';
- $formmail->substit['__CONTACTCIVNAME__']='';
-
- //Find the good contact adress
- $custcontact='';
- $contactarr=array();
- $contactarr=$object->liste_contact(-1,'external');
-
- if (is_array($contactarr) && count($contactarr)>0) {
- foreach($contactarr as $contact) {
- if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) {
-
+ $formmail->substit ['__FACREF__'] = $object->ref;
+ $formmail->substit ['__SIGNATURE__'] = $user->signature;
+ $formmail->substit ['__REFCLIENT__'] = $object->ref_client;
+ $formmail->substit ['__PERSONALIZED__'] = '';
+ $formmail->substit ['__CONTACTCIVNAME__'] = '';
+
+ // Find the good contact adress
+ $custcontact = '';
+ $contactarr = array();
+ $contactarr = $object->liste_contact(- 1, 'external');
+
+ if (is_array($contactarr) && count($contactarr) > 0) {
+ foreach ($contactarr as $contact) {
+ if ($contact ['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) {
+
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
-
- $contactstatic=new Contact($db);
- $contactstatic->fetch($contact['id']);
- $custcontact=$contactstatic->getFullName($langs,1);
+
+ $contactstatic = new Contact($db);
+ $contactstatic->fetch($contact ['id']);
+ $custcontact = $contactstatic->getFullName($langs, 1);
}
}
-
- if (!empty($custcontact)) {
- $formmail->substit['__CONTACTCIVNAME__']=$custcontact;
+
+ if (! empty($custcontact)) {
+ $formmail->substit ['__CONTACTCIVNAME__'] = $custcontact;
}
}
-
-
+
// Tableau des parametres complementaires du post
- $formmail->param['action']=$action;
- $formmail->param['models']=$modelmail;
- $formmail->param['facid']=$object->id;
- $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
-
+ $formmail->param ['action'] = $action;
+ $formmail->param ['models'] = $modelmail;
+ $formmail->param ['facid'] = $object->id;
+ $formmail->param ['returnurl'] = $_SERVER ["PHP_SELF"] . '?id=' . $object->id;
+
// Init list of files
- if (GETPOST("mode")=='init')
- {
+ if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
- $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
+ $formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
-
+
print $formmail->get_form();
-
+
print ' ';
}
}
-dol_htmloutput_mesg('',$mesgs);
+dol_htmloutput_mesg('', $mesgs);
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index 880f13d67d7..eec9220afa4 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -16,6 +16,9 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
+ * Note: Page can be call with param mode=sendremind to bring feature to send
+ * remind by emails.
*/
/**
@@ -128,7 +131,7 @@ if ($action == 'presend' && GETPOST('sendmail'))
'__REFCLIENT__' => $object->thirdparty->name
);
- make_substitutions($message, $substitutionarray);
+ $message=make_substitutions($message, $substitutionarray);
$actiontypecode='AC_FAC';
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index fa61089a853..2dc8a454ae0 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1264,9 +1264,10 @@ class Form
* @param string $selected_input_value Value of preselected input text (with ajax)
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
* @param array $ajaxoptions Options for ajax_autocompleter
+ * @param int $socid Thridparty Id
* @return void
*/
- function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array())
+ function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(),$socid=0)
{
global $langs,$conf;
@@ -1285,6 +1286,10 @@ class Form
}
// mode=1 means customers products
$urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished;
+ //Price by customer
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
+ $urloption.='&socid='.$socid;
+ }
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : ';
else if ($hidelabel > 1) {
@@ -1301,7 +1306,7 @@ class Form
}
else
{
- print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0);
+ print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0,$socid);
}
}
@@ -1317,9 +1322,10 @@ class Form
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param int $finished Filter on finished field: 2=No filter
* @param int $outputmode 0=HTML select string, 1=Array
+ * @param int $socid Thridparty Id
* @return array Array of keys for json
*/
- function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0)
+ function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0)
{
global $langs,$conf,$user,$db;
@@ -1328,6 +1334,13 @@ class Form
$sql = "SELECT ";
$sql.= " p.rowid, p.label, p.ref, p.description, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.stock";
+
+ //Price by customer
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
+ $sql.=' ,pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
+ $sql.=' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx';
+ }
+
// Multilang : we add translation
if (! empty($conf->global->MAIN_MULTILANGS))
{
@@ -1337,15 +1350,19 @@ class Form
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{
$sql.= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
- if ($price_level >= 1) $sql.= " AND price_level=".$price_level;
+ if ($price_level >= 1 && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND price_level=".$price_level;
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1) as price_rowid";
$sql.= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
- if ($price_level >= 1) $sql.= " AND price_level=".$price_level;
+ if ($price_level >= 1 && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND price_level=".$price_level;
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1) as price_by_qty";
}
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
+ //Price by customer
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid";
+ }
// Multilang : we add translation
if (! empty($conf->global->MAIN_MULTILANGS))
{
@@ -1407,7 +1424,7 @@ class Form
$optJson = array();
$objp = $this->db->fetch_object($result);
- if (!empty($objp->price_by_qty) && $objp->price_by_qty == 1)
+ if (!empty($objp->price_by_qty) && $objp->price_by_qty == 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{ // Price by quantity will return many prices for the same product
$sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
@@ -1523,7 +1540,7 @@ class Form
$found=0;
// Multiprice
- if ($price_level >= 1) // If we need a particular price level (from 1 to 6)
+ if ($price_level >= 1 && $conf->global->PRODUIT_MULTIPRICES) // If we need a particular price level (from 1 to 6)
{
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
@@ -1533,7 +1550,7 @@ class Form
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1";
- dol_syslog(get_class($this)."::constructProductListOption search price for level '.$price_level.' sql=".$sql);
+ dol_syslog(get_class($this).'::constructProductListOption search price for level '.$price_level.' sql='.$sql);
$result2 = $this->db->query($sql);
if ($result2)
{
@@ -1564,7 +1581,7 @@ class Form
}
// Price by quantity
- if (!empty($objp->quantity) && $objp->quantity >= 1)
+ if (!empty($objp->quantity) && $objp->quantity >= 1 && $conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)
{
$found = 1;
$outqty=$objp->quantity;
@@ -1599,6 +1616,29 @@ class Form
$opt.=" - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
$outval.=" - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
}
+
+ //Price by customer
+ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
+ if (!empty($objp->idprodcustprice)) {
+ $found = 1;
+
+ if ($objp->custprice_base_type == 'HT')
+ {
+ $opt.= price($objp->custprice,1).' '.$currencytext.' '.$langs->trans("HT");
+ $outval.= price($objp->custprice,1).' '.$currencytextnoent.' '.$langs->transnoentities("HT");
+ }
+ else
+ {
+ $opt.= price($objp->custprice_ttc,1).' '.$currencytext.' '.$langs->trans("TTC");
+ $outval.= price($objp->custprice_ttc,1).' '.$currencytextnoent.' '.$langs->transnoentities("TTC");
+ }
+
+ $outprice_ht=price($objp->custprice);
+ $outprice_ttc=price($objp->custprice_ttc);
+ $outpricebasetype=$objp->custprice_base_type;
+ $outtva_tx=$objp->custtva_tx;
+ }
+ }
// If level no defined or multiprice not found, we used the default price
if (! $found)
@@ -3735,7 +3775,7 @@ class Form
*
* @param string $htmlname Name of html select area
* @param array $array Array with key+value
- * @param int $id Preselected key
+ * @param string $id Preselected key
* @param int $show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key
diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php
new file mode 100644
index 00000000000..4be805c379e
--- /dev/null
+++ b/htdocs/core/db/Database.interface.php
@@ -0,0 +1,465 @@
+
+ * Copyright (C) 2002-2007 Rodolphe Quiedeville
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2014 Raphaël Doursenaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * Class to manage Dolibarr database access for a Mysql database
+ */
+interface Database
+{
+ /**
+ * Format a SQL IF
+ *
+ * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
+ * @param string $resok resultat si test egal
+ * @param string $resko resultat si test non egal
+ * @return string SQL string
+ */
+ function ifsql($test, $resok, $resko);
+
+ /**
+ * Return datas as an array
+ *
+ * @param Resultset $resultset Resultset of request
+ * @return array Array
+ */
+ function fetch_row($resultset);
+
+ /**
+ * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
+ * Function to use to build INSERT, UPDATE or WHERE predica
+ *
+ * @param string $param Date TMS to convert
+ * @return string Date in a string YYYYMMDDHHMMSS
+ */
+ function idate($param);
+
+ /**
+ * Return last error code
+ *
+ * @return string lasterrno
+ */
+ function lasterrno();
+
+ /**
+ * Start transaction
+ *
+ * @return int 1 if transaction successfuly opened or already opened, 0 if error
+ */
+ function begin();
+
+ /**
+ * Create a new database
+ * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
+ * We force to create database with charset this->forcecharset and collate this->forcecollate
+ *
+ * @param string $database Database name to create
+ * @param string $charset Charset used to store data
+ * @param string $collation Charset used to sort data
+ * @param string $owner Username of database owner
+ * @return resource resource defined if OK, null if KO
+ */
+ function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
+
+ /**
+ * Return version of database server into an array
+ *
+ * @return array Version array
+ */
+ function getVersionArray();
+
+ /**
+ * Convert a SQL request in Mysql syntax to native syntax
+ *
+ * @param string $line SQL request line to convert
+ * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
+ * @return string SQL request line converted
+ */
+ static function convertSQLFromMysql($line, $type = 'ddl');
+
+ /**
+ * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
+ *
+ * @param resultset $resultset Curseur de la requete voulue
+ * @return int Nombre de lignes
+ * @see num_rows
+ */
+ function affected_rows($resultset);
+
+ /**
+ * Return description of last error
+ *
+ * @return string Error text
+ */
+ function error();
+
+ /**
+ * Return label of manager
+ *
+ * @return string Label
+ */
+ function getLabel();
+
+ /**
+ * List tables into a database
+ *
+ * @param string $database Name of database
+ * @param string $table Nmae of table filter ('xxx%')
+ * @return resource Resource
+ */
+ function DDLListTables($database, $table = '');
+
+ /**
+ * Return last request executed with query()
+ *
+ * @return string Last query
+ */
+ function lastquery();
+
+ /**
+ * Define sort criteria of request
+ *
+ * @param string $sortfield List of sort fields
+ * @param string $sortorder Sort order
+ * @return string String to provide syntax of a sort sql string
+ */
+ function order($sortfield = 0, $sortorder = 0);
+
+ /**
+ * Decrypt sensitive data in database
+ *
+ * @param string $value Value to decrypt
+ * @return string Decrypted value if used
+ */
+ function decrypt($value);
+
+ /**
+ * Return datas as an array
+ *
+ * @param Resultset $resultset Resultset of request
+ * @return array Array
+ */
+ function fetch_array($resultset);
+
+ /**
+ * Return last error label
+ *
+ * @return string lasterror
+ */
+ function lasterror();
+
+ /**
+ * Escape a string to insert data
+ *
+ * @param string $stringtoencode String to escape
+ * @return string String escaped
+ */
+ function escape($stringtoencode);
+
+ /**
+ * Get last ID after an insert INSERT
+ *
+ * @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql
+ * @param string $fieldid Field name
+ * @return int Id of row
+ */
+ function last_insert_id($tab, $fieldid = 'rowid');
+
+ /**
+ * Return full path of restore program
+ *
+ * @return string Full path of restore program
+ */
+ function getPathOfRestore();
+
+ /**
+ * Annulation d'une transaction et retour aux anciennes valeurs
+ *
+ * @param string $log Add more log to default log line
+ * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
+ */
+ function rollback($log = '');
+
+ /**
+ * Execute a SQL request and return the resultset
+ *
+ * @param string $query SQL query string
+ * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions).
+ * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
+ * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
+ * @return resource Resultset of answer
+ */
+ function query($query, $usesavepoint = 0, $type = 'auto');
+
+ /**
+ * Connexion to server
+ *
+ * @param string $host database server host
+ * @param string $login login
+ * @param string $passwd password
+ * @param string $name name of database (not used for mysql, used for pgsql)
+ * @param string $port Port of database server
+ * @return resource Database access handler
+ * @see close
+ */
+ function connect($host, $login, $passwd, $name, $port = 0);
+
+ /**
+ * Define limits and offset of request
+ *
+ * @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
+ * @param int $offset Numero of line from where starting fetch
+ * @return string String with SQL syntax to add a limit and offset
+ */
+ function plimit($limit = 0, $offset = 0);
+
+ /**
+ * Return value of server parameters
+ *
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
+ */
+ function getServerParametersValues($filter = '');
+
+ /**
+ * Return value of server status
+ *
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
+ */
+ function getServerStatusValues($filter = '');
+
+ /**
+ * Return collation used in database
+ *
+ * @return string Collation value
+ */
+ function getDefaultCollationDatabase();
+
+ /**
+ * Return number of lines for result of a SELECT
+ *
+ * @param Resultset $resultset Resulset of requests
+ * @return int Nb of lines
+ * @see affected_rows
+ */
+ function num_rows($resultset);
+
+ /**
+ * Return full path of dump program
+ *
+ * @return string Full path of dump program
+ */
+ function getPathOfDump();
+
+ /**
+ * Return version of database client driver
+ *
+ * @return string Version string
+ */
+ function getDriverInfo();
+
+ /**
+ * Return generic error code of last operation.
+ *
+ * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)
+ */
+ function errno();
+
+ /**
+ * Create a table into database
+ *
+ * @param string $table Nom de la table
+ * @param array $fields Tableau associatif [nom champ][tableau des descriptions]
+ * @param string $primary_key Nom du champ qui sera la clef primaire
+ * @param string $type Type de la table
+ * @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
+ * @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
+ * @param string $keys Tableau des champs cles noms => valeur
+ * @return int <0 if KO, >=0 if OK
+ */
+ function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = "", $fulltext_keys = "", $keys = "");
+
+ /**
+ * Return list of available charset that can be used to store data in database
+ *
+ * @return array List of Charset
+ */
+ function getListOfCharacterSet();
+
+ /**
+ * Create a new field into table
+ *
+ * @param string $table Name of table
+ * @param string $field_name Name of field to add
+ * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
+ * @param string $field_position Optionnel ex.: "after champtruc"
+ * @return int <0 if KO, >0 if OK
+ */
+ function DDLAddField($table, $field_name, $field_desc, $field_position = "");
+
+ /**
+ * Drop a field from table
+ *
+ * @param string $table Name of table
+ * @param string $field_name Name of field to drop
+ * @return int <0 if KO, >0 if OK
+ */
+ function DDLDropField($table, $field_name);
+
+ /**
+ * Update format of a field into a table
+ *
+ * @param string $table Name of table
+ * @param string $field_name Name of field to modify
+ * @param string $field_desc Array with description of field format
+ * @return int <0 if KO, >0 if OK
+ */
+ function DDLUpdateField($table, $field_name, $field_desc);
+
+ /**
+ * Return list of available collation that can be used for database
+ *
+ * @return array List of Collation
+ */
+ function getListOfCollation();
+
+ /**
+ * Return a pointer of line with description of a table or field
+ *
+ * @param string $table Name of table
+ * @param string $field Optionnel : Name of field if we want description of field
+ * @return resource Resource
+ */
+ function DDLDescTable($table, $field = "");
+
+ /**
+ * Return version of database server
+ *
+ * @return string Version string
+ */
+ function getVersion();
+
+ /**
+ * Return charset used to store data in database
+ *
+ * @return string Charset
+ */
+ function getDefaultCharacterSetDatabase();
+
+ /**
+ * Create a user and privileges to connect to database (even if database does not exists yet)
+ *
+ * @param string $dolibarr_main_db_host Ip serveur
+ * @param string $dolibarr_main_db_user Nom user a creer
+ * @param string $dolibarr_main_db_pass Mot de passe user a creer
+ * @param string $dolibarr_main_db_name Database name where user must be granted
+ * @return int <0 if KO, >=0 if OK
+ */
+ function DDLCreateUser(
+ $dolibarr_main_db_host,
+ $dolibarr_main_db_user,
+ $dolibarr_main_db_pass,
+ $dolibarr_main_db_name
+ );
+
+ /**
+ * Convert (by PHP) a PHP server TZ string date into a GM Timestamps date
+ * 19700101020000 -> 3600 with TZ+1
+ *
+ * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
+ * @return date Date TMS
+ */
+ function jdate($string);
+
+ /**
+ * Encrypt sensitive data in database
+ * Warning: This function includes the escape, so it must use direct value
+ *
+ * @param string $fieldorvalue Field name or value to encrypt
+ * @param int $withQuotes Return string with quotes
+ * @return string XXX(field) or XXX('value') or field or 'value'
+ */
+ function encrypt($fieldorvalue, $withQuotes = 0);
+
+ /**
+ * Validate a database transaction
+ *
+ * @param string $log Add more log to default log line
+ * @return int 1 if validation is OK or transaction level no started, 0 if ERROR
+ */
+ function commit($log = '');
+
+ /**
+ * List information of columns into a table.
+ *
+ * @param string $table Name of table
+ * @return array Tableau des informations des champs de la table
+ */
+ function DDLInfoTable($table);
+
+ /**
+ * Free last resultset used.
+ *
+ * @param resultset $resultset Curseur de la requete voulue
+ * @return void
+ */
+ function free($resultset = 0);
+
+ /**
+ * Close database connexion
+ *
+ * @return boolean True if disconnect successfull, false otherwise
+ * @see connect
+ */
+ function close();
+
+ /**
+ * Return last query in error
+ *
+ * @return string lastqueryerror
+ */
+ function lastqueryerror();
+
+ /**
+ * Return connexion ID
+ *
+ * @return string Id connexion
+ */
+ function DDLGetConnectId();
+
+ /**
+ * Renvoie la ligne courante (comme un objet) pour le curseur resultset
+ *
+ * @param Resultset $resultset Curseur de la requete voulue
+ * @return Object Object result line or false if KO or end of cursor
+ */
+ function fetch_object($resultset);
+
+ /**
+ * Select a database
+ *
+ * @param string $database Name of database
+ * @return boolean true if OK, false if KO
+ */
+ function select_db($database);
+
+}
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 43b05aea150..6f5a75b35ab 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -1,6 +1,6 @@
+ * Copyright (C) 2013-2014 Raphaël Doursenaud
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,10 +21,12 @@
* \brief Class file to manage Dolibarr database access
*/
+require_once DOL_DOCUMENT_ROOT .'/core/db/Database.interface.php';
+
/**
* Class to manage Dolibarr database access
*/
-abstract class DoliDB
+abstract class DoliDB implements Database
{
//! Database handler
public $db;
@@ -92,6 +94,5 @@ abstract class DoliDB
return '';
}
}
-
}
diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php
index c50a7ed8925..e80c2957088 100644
--- a/htdocs/core/db/mssql.class.php
+++ b/htdocs/core/db/mssql.class.php
@@ -237,6 +237,9 @@ class DoliDBMssql extends DoliDB
*/
function getDriverInfo()
{
+ // FIXME: Dummy method
+ // TODO: Implement
+
return '';
}
@@ -310,15 +313,16 @@ class DoliDBMssql extends DoliDB
/**
* Annulation d'une transaction et retour aux anciennes valeurs
*
- * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
+ * @param string $log Add more log to default log line
+ * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
*/
- function rollback()
+ function rollback($log='')
{
if ($this->transaction_opened<=1)
{
$ret=$this->query("ROLLBACK TRANSACTION");
$this->transaction_opened=0;
- dol_syslog("ROLLBACK Transaction",LOG_DEBUG);
+ dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
return $ret;
}
else
@@ -804,6 +808,23 @@ class DoliDBMssql extends DoliDB
return $this->_results;
}
+ /**
+ * List information of columns into a table.
+ *
+ * @param string $table Name of table
+ * @return array Tableau des informations des champs de la table
+ */
+ function DDLInfoTable($table)
+ {
+
+ // FIXME: Dummy method
+ // TODO: Implement
+ // May help: https://stackoverflow.com/questions/600446/sql-server-how-do-you-return-the-column-names-from-a-table
+
+ $infotables=array();
+ return $infotables;
+ }
+
/**
* Create a table into database
*
@@ -975,6 +996,24 @@ class DoliDBMssql extends DoliDB
else return 1;
}
+ /**
+ * Create a user and privileges to connect to database (even if database does not exists yet)
+ *
+ * @param string $dolibarr_main_db_host Ip serveur
+ * @param string $dolibarr_main_db_user Nom user a creer
+ * @param string $dolibarr_main_db_pass Mot de passe user a creer
+ * @param string $dolibarr_main_db_name Database name where user must be granted
+ * @return int <0 if KO, >=0 if OK
+ */
+ function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
+ {
+ // FIXME: Dummy method
+ // TODO: Implement
+ // May help: http://msdn.microsoft.com/fr-fr/library/ms173463.aspx
+
+ // Always fail for now
+ return -1;
+ }
/**
* Return charset used to store data in database
@@ -983,15 +1022,9 @@ class DoliDBMssql extends DoliDB
*/
function getDefaultCharacterSetDatabase()
{
- /*
- $resql=$this->query('SHOW VARIABLES LIKE \'character_set_database\'');
- if (!$resql)
- {
- return $this->forcecharset;
- }
- $liste=$this->fetch_array($resql);
- return $liste['Value'];
- */
+ // FIXME: Dummy method
+ // TODO: Implement
+
return '';
}
@@ -1002,25 +1035,10 @@ class DoliDBMssql extends DoliDB
*/
function getListOfCharacterSet()
{
- /*
- $resql=$this->query('SHOW CHARSET');
- $liste = array();
- if ($resql)
- {
- $i = 0;
- while ($obj = $this->fetch_object($resql) )
- {
- $liste[$i]['charset'] = $obj->Charset;
- $liste[$i]['description'] = $obj->Description;
- $i++;
- }
- $this->free($resql);
- } else {
- return null;
- }
- return $liste;
- */
- return ''; // attente debuggage
+ // FIXME: Dummy method
+ // TODO: Implement
+
+ return '';
}
/**
@@ -1046,24 +1064,10 @@ class DoliDBMssql extends DoliDB
*/
function getListOfCollation()
{
- /*
- $resql=$this->query('SHOW COLLATION');
- $liste = array();
- if ($resql)
- {
- $i = 0;
- while ($obj = $this->fetch_object($resql) )
- {
- $liste[$i]['collation'] = $obj->Collation;
- $i++;
- }
- $this->free($resql);
- } else {
- return null;
- }
- return $liste;
- */
- return ''; // attente debugage
+ // FIXME: Dummy method
+ // TODO: Implement
+
+ return '';
}
/**
@@ -1073,6 +1077,8 @@ class DoliDBMssql extends DoliDB
*/
function getPathOfDump()
{
+ // FIXME: Dummy method
+ // TODO: Implement
return '';
}
@@ -1084,9 +1090,42 @@ class DoliDBMssql extends DoliDB
*/
function getPathOfRestore()
{
+ // FIXME: Dummy method
+ // TODO: Implement
return '';
}
+
+ /**
+ * Return value of server parameters
+ *
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
+ */
+ function getServerParametersValues($filter='')
+ {
+ // FIXME: Dummy method
+ // TODO: Implement
+ // May help: SELECT SERVERPROPERTY
+
+ $result=array();
+ return $result;
+ }
+
+ /**
+ * Return value of server status
+ *
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
+ */
+ function getServerStatusValues($filter='')
+ {
+ // FIXME: Dummy method
+ // TODO: Implement
+ // May help: http://www.experts-exchange.com/Database/MS-SQL-Server/Q_20971756.html
+
+ return array();
+ }
}
?>
diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php
index 86100d6d7d3..59d302aa3f2 100644
--- a/htdocs/core/db/mysql.class.php
+++ b/htdocs/core/db/mysql.class.php
@@ -84,6 +84,7 @@ class DoliDBMysql extends DoliDB
{
global $conf,$langs;
+ // Note that having "static" property for "$forcecharset" and "$forcecollate" will make error here in strict mode, so they are not static
if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
@@ -1196,10 +1197,10 @@ class DoliDBMysql extends DoliDB
}
/**
- * Return value of server parameters
+ * Return value of server parameters
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerParametersValues($filter='')
{
@@ -1218,17 +1219,17 @@ class DoliDBMysql extends DoliDB
}
/**
- * Return value of server status
+ * Return value of server status
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerStatusValues($filter='')
{
$result=array();
$sql='SHOW STATUS';
- if ($filter) $sql.=" LIKE '".addslashes($filter)."'";
+ if ($filter) $sql.=" LIKE '".$this->escape($filter)."'";
$resql=$this->query($sql);
if ($resql)
{
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index 4cc57a880b8..d26026e9f95 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -84,9 +84,9 @@ class DoliDBMysqli extends DoliDB
{
global $conf,$langs;
- // TODO error in strict mode (static property for "$forcecharset" and "$forcecollate")
- //if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
- //if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
+ // Note that having "static" property for "$forcecharset" and "$forcecollate" will make error here in strict mode, so they are not static
+ if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
+ if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
$this->database_user=$user;
@@ -233,6 +233,16 @@ class DoliDBMysqli extends DoliDB
return $this->db;
}
+ /**
+ * Return label of manager
+ *
+ * @return string Label
+ */
+ function getLabel()
+ {
+ return $this->label;
+ }
+
/**
* Return version of database server
*
@@ -1190,10 +1200,10 @@ class DoliDBMysqli extends DoliDB
}
/**
- * Return value of server parameters
+ * Return value of server parameters
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerParametersValues($filter='')
{
@@ -1212,17 +1222,17 @@ class DoliDBMysqli extends DoliDB
}
/**
- * Return value of server status
+ * Return value of server status (current indicators on memory, cache...)
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerStatusValues($filter='')
{
$result=array();
$sql='SHOW STATUS';
- if ($filter) $sql.=" LIKE '".addslashes($filter)."'";
+ if ($filter) $sql.=" LIKE '".$this->escape($filter)."'";
$resql=$this->query($sql);
if ($resql)
{
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 531427b9547..cfb25e76508 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -85,6 +85,7 @@ class DoliDBPgsql extends DoliDB
{
global $conf,$langs;
+ // Note that having "static" property for "$forcecharset" and "$forcecollate" will make error here in strict mode, so they are not static
if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
@@ -466,6 +467,9 @@ class DoliDBPgsql extends DoliDB
*/
function getDriverInfo()
{
+ // FIXME: Dummy method
+ // TODO: Implement
+
return '';
}
@@ -541,16 +545,17 @@ class DoliDBPgsql extends DoliDB
/**
* Annulation d'une transaction et retour aux anciennes valeurs
*
- * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
+ * @param string $log Add more log to default log line
+ * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
*/
- function rollback()
+ function rollback($log='')
{
dol_syslog('',0,-1);
if ($this->transaction_opened<=1)
{
$ret=$this->query("ROLLBACK;");
$this->transaction_opened=0;
- dol_syslog("ROLLBACK Transaction",LOG_DEBUG);
+ dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
return $ret;
}
else
@@ -1382,17 +1387,17 @@ class DoliDBPgsql extends DoliDB
}
/**
- * Return value of server parameters
+ * Return value of server parameters
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerParametersValues($filter='')
{
$result=array();
$resql='select name,setting from pg_settings';
- if ($filter) $resql.=" WHERE name = '".addslashes($filter)."'";
+ if ($filter) $resql.=" WHERE name = '".$this->escape($filter)."'";
$resql=$this->query($resql);
if ($resql)
{
@@ -1402,5 +1407,27 @@ class DoliDBPgsql extends DoliDB
return $result;
}
+
+ /**
+ * Return value of server status
+ *
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
+ */
+ function getServerStatusValues($filter='')
+ {
+ /* This is to return current running requests.
+ $sql='SELECT datname,procpid,current_query FROM pg_stat_activity ORDER BY procpid';
+ if ($filter) $sql.=" LIKE '".$this->escape($filter)."'";
+ $resql=$this->query($sql);
+ if ($resql)
+ {
+ $obj=$this->fetch_object($resql);
+ $result[$obj->Variable_name]=$obj->Value;
+ }
+ */
+
+ return array();
+ }
}
?>
diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php
index 37460f0e23c..496de961d68 100644
--- a/htdocs/core/db/sqlite.class.php
+++ b/htdocs/core/db/sqlite.class.php
@@ -84,6 +84,7 @@ class DoliDBSqlite extends DoliDB
{
global $conf,$langs;
+ // Note that having "static" property for "$forcecharset" and "$forcecollate" will make error here in strict mode, so they are not static
if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
@@ -389,6 +390,9 @@ class DoliDBSqlite extends DoliDB
*/
function getDriverInfo()
{
+ // FIXME: Dummy method
+ // TODO: Implement
+
return '';
}
@@ -1305,10 +1309,10 @@ class DoliDBSqlite extends DoliDB
}
/**
- * Return value of server parameters
+ * Return value of server parameters
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerParametersValues($filter='')
{
@@ -1327,17 +1331,17 @@ class DoliDBSqlite extends DoliDB
}
/**
- * Return value of server status
+ * Return value of server status
*
- * @param string $filter Filter list on a particular value
- * @return string Value for parameter
+ * @param string $filter Filter list on a particular value
+ * @return array Array of key-values (key=>value)
*/
function getServerStatusValues($filter='')
{
$result=array();
$sql='SHOW STATUS';
- if ($filter) $sql.=" LIKE '".addslashes($filter)."'";
+ if ($filter) $sql.=" LIKE '".$this->escape($filter)."'";
$resql=$this->query($sql);
if ($resql)
{
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 42da0b04d38..aa0a422d91f 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -3,7 +3,7 @@
* Copyright (C) 2006 Rodolphe Quiedeville
* Copyright (C) 2007 Patrick Raguin
* Copyright (C) 2010-2012 Regis Houssin
- * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013-2014 Florian Henry
* Copyright (C) 2013 Juanjo Menent
* Copyright (C) 2013 Christophe Battarel
* Copyright (C) 2013 Alexandre Spangaro
@@ -136,6 +136,16 @@ function societe_prepare_head($object)
$h++;
}
+ if (($object->client==1 || $object->client==2 || $object->client==3) && (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )))
+ {
+ $langs->load("products");
+ // price
+ $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id;
+ $head[$h][1] = $langs->trans("CustomerPrices");
+ $head[$h][2] = 'price';
+ $h++;
+ }
+
// Log
$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Info");
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 19d2adeea93..3e73d4320c3 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2868,7 +2868,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
global $db, $conf, $mysoc;
if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) $thirdparty_seller=$mysoc;
-
+
dol_syslog("get_localtax tva=".$tva." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')."/country_code=".(is_object($thirdparty_buyer)?$thirdparty_buyer->country_code:'')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
// Some test to guess with no need to make database access
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 8d9c3bdd18b..205791624c1 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -270,7 +270,7 @@ class modSociete extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.nom'=>"Text",'s.status'=>"Number",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'p.libelle'=>"List:c_pays:libelle:libelle",'p.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Number",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text');
$this->export_entities_array[$r]=array(); // We define here only fields that use another picto
// Add extra fields
- $sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
+ $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
diff --git a/htdocs/core/tpl/objectline_add.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php
index 0c03206ae67..d27268be121 100644
--- a/htdocs/core/tpl/objectline_add.tpl.php
+++ b/htdocs/core/tpl/objectline_add.tpl.php
@@ -107,7 +107,7 @@ if (! empty($conf->margin->enabled)) {
'select_type'
)
);
- $form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 3, $ajaxoptions);
+ $form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 3, $ajaxoptions,$buyer->id);
}
?>
|
@@ -270,6 +270,9 @@ $(document).ready(function() {
'id': $(this).val(),
'price_level': price_level)?1:$buyer->price_level; ?>,
'pbq': $("option:selected", this).attr('pbq')
+ global->PRODUIT_CUSTOMER_PRICES )) {?>
+ ,'socid': id; ?>
+
},
function(data) {
if (typeof data != 'undefined') {
diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php
index acd06c807d3..ff39c9b705c 100644
--- a/htdocs/core/tpl/predefinedproductline_create.tpl.php
+++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php
@@ -101,7 +101,7 @@ else {
echo '';
$filtertype='';
if (! empty($object->element) && $object->element == 'contrat') $filtertype='1';
- $form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level);
+ $form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level, 1, 2, '', 3, array(),$buyer->id);
echo ' ';
if (is_object($hookmanager))
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 6ab80b6ad88..0bb1b6c12b2 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -618,6 +618,15 @@ class InterfaceActionsAuto
if ($ok)
{
$now=dol_now();
+
+ if(isset($_SESSION['listofnames']))
+ {
+ $attachs=$_SESSION['listofnames'];
+ if($attachs && strpos($action,'SENTBYMAIL'))
+ {
+ $object->actionmsg.="\n".$langs->transnoentities("AttachedFiles").': '.$attachs;
+ }
+ }
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 15e08bad604..8af37f67361 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -31,7 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php';
if (! empty($conf->projet->enabled))
{
@@ -858,7 +857,8 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint
$form = new Form($db);
$formfile = new FormFile($db);
-$formcontract = new FormContract($db);
+if ($conf->contrat->enabled)
+ $formcontract = new FormContract($db);
llxHeader('',$langs->trans("Fichinter"));
@@ -983,7 +983,7 @@ if ($action == 'create')
$numprojet=$formproject->select_projects($soc->id,GETPOST('projectid','int'),'projectid');
if ($numprojet==0)
{
- print ' '.$langs->trans("AddProject").' ';
+ print ' '.$langs->trans("AddProject").' ';
}
print ' ';
}
diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
index eb02007581d..0a845dc76f8 100755
--- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
+++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
@@ -957,3 +957,56 @@ INSERT INTO llx_accountingaccount (fk_pcg_version, pcg_type, pcg_subtype, accoun
INSERT INTO llx_accountingaccount (fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUE ('PCMN-BASE', 'PROD', 'XXXXXX', '793', '79', 'Perte à reporter', '1');
INSERT INTO llx_accountingaccount (fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUE ('PCMN-BASE', 'PROD', 'XXXXXX', '794', '79', 'Intervention d''associés (ou du propriétaire) dans la perte', '1');
+
+ALTER TABLE llx_projet_task ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
+
+create table llx_product_customer_price
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime,
+ tms timestamp,
+ fk_product integer NOT NULL,
+ fk_soc integer NOT NULL,
+ price double(24,8) DEFAULT 0,
+ price_ttc double(24,8) DEFAULT 0,
+ price_min double(24,8) DEFAULT 0,
+ price_min_ttc double(24,8) DEFAULT 0,
+ price_base_type varchar(3) DEFAULT 'HT',
+ tva_tx double(6,3),
+ recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
+ fk_user integer,
+ import_key varchar(14) -- Import key
+)ENGINE=innodb;
+
+ALTER TABLE llx_product_customer_price ADD INDEX idx_product_customer_price_fk_user (fk_user);
+
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
+
+ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_product_fk_soc (fk_product, fk_soc);
+
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product(rowid) ON DELETE CASCADE;
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid) ON DELETE CASCADE;
+
+
+create table llx_product_customer_price_log
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime,
+ fk_product integer NOT NULL,
+ fk_soc integer NOT NULL,
+ price double(24,8) DEFAULT 0,
+ price_ttc double(24,8) DEFAULT 0,
+ price_min double(24,8) DEFAULT 0,
+ price_min_ttc double(24,8) DEFAULT 0,
+ price_base_type varchar(3) DEFAULT 'HT',
+ tva_tx double(6,3),
+ recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
+ fk_user integer,
+ import_key varchar(14) -- Import key
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.key.sql b/htdocs/install/mysql/tables/llx_product_customer_price.key.sql
new file mode 100644
index 00000000000..8ae2e2ca9a8
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_product_customer_price.key.sql
@@ -0,0 +1,30 @@
+-- ============================================================================
+-- Copyright (C) 2003 Rodolphe Quiedeville
+-- Copyright (C) 2005-2012 Laurent Destailleur
+-- Copyright (C) 2009-2012 Regis Houssin
+-- Copyright (C) 2013 Florian Henry
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ============================================================================
+
+
+ALTER TABLE llx_product_customer_price ADD INDEX idx_product_customer_price_fk_user (fk_user);
+
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
+
+ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_product_fk_soc (fk_product, fk_soc);
+
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product(rowid) ON DELETE CASCADE;
+ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid) ON DELETE CASCADE;
diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.sql b/htdocs/install/mysql/tables/llx_product_customer_price.sql
new file mode 100644
index 00000000000..0dd37358682
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_product_customer_price.sql
@@ -0,0 +1,42 @@
+-- ============================================================================
+-- Copyright (C) 2003 Rodolphe Quiedeville
+-- Copyright (C) 2009-2011 Laurent Destailleur
+-- Copyright (C) 2009-2013 Regis Houssin
+-- Copyright (C) 2012 Juanjo Menent
+-- Copyright (C) 2013 Florian Henry
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ============================================================================
+
+create table llx_product_customer_price
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime,
+ tms timestamp,
+ fk_product integer NOT NULL,
+ fk_soc integer NOT NULL,
+ price double(24,8) DEFAULT 0,
+ price_ttc double(24,8) DEFAULT 0,
+ price_min double(24,8) DEFAULT 0,
+ price_min_ttc double(24,8) DEFAULT 0,
+ price_base_type varchar(3) DEFAULT 'HT',
+ tva_tx double(6,3),
+ recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
+ fk_user integer,
+ import_key varchar(14) -- Import key
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql
new file mode 100644
index 00000000000..b25bd982aab
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql
@@ -0,0 +1,39 @@
+-- ============================================================================
+-- Copyright (C) 2005 Rodolphe Quiedeville
+-- Copyright (C) 2009 Laurent Destailleur
+-- Copyright (C) 2013 Florian Henry
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ============================================================================
+
+create table llx_product_customer_price_log
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime,
+ fk_product integer NOT NULL,
+ fk_soc integer NOT NULL,
+ price double(24,8) DEFAULT 0,
+ price_ttc double(24,8) DEFAULT 0,
+ price_min double(24,8) DEFAULT 0,
+ price_min_ttc double(24,8) DEFAULT 0,
+ price_base_type varchar(3) DEFAULT 'HT',
+ tva_tx double(6,3),
+ recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
+ fk_user integer,
+ import_key varchar(14) -- Import key
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_projet_task.sql b/htdocs/install/mysql/tables/llx_projet_task.sql
index 1b73cc71781..98c8845974e 100644
--- a/htdocs/install/mysql/tables/llx_projet_task.sql
+++ b/htdocs/install/mysql/tables/llx_projet_task.sql
@@ -21,6 +21,7 @@ create table llx_projet_task
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(50),
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_projet integer NOT NULL,
fk_task_parent integer DEFAULT 0 NOT NULL,
datec datetime, -- date creation
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 794d5f05c4a..15d5b038f7c 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -380,12 +380,16 @@ DefaultLink=Default link
ValueOverwrittenByUserSetup=Warning, this value may be overwritten by user specific setup (each user can set his own clicktodial url)
ExternalModule=External module - Installed into directory %s
BarcodeInitForThirdparties=Mass barcode init for thirdparties
-BarcodeInitForProductsOrServices=Mass barcode init for products or services
+BarcodeInitForProductsOrServices=Mass barcode init or reset for products or services
CurrentlyNWithoutBarCode=Currently, you have %s records on %s %s without barcode defined.
-InitEmptyBarCode=Init the %s barcode
+InitEmptyBarCode=Init value for next %s empty records
+EraseAllCurrentBarCode=Erase all current barcode values
+ConfirmEraseAllCurrentBarCode=Are you sure you want to erase all current barcode values ?
+AllBarcodeReset=All barcode values have been removed
NoBarcodeNumberingTemplateDefined=No numbering barcode template enabled into barcode module setup.
NoRecordWithoutBarcodeDefined=No record with no barcode value defined.
+
# Modules
Module0Name=Users & groups
Module0Desc=Users and groups management
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index fa3144d0475..a84d929550a 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -220,5 +220,10 @@ DefinitionOfBarCodeForProductNotComplete=Definition of type or value of bar code
DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar code non complete for thirdparty %s.
BarCodeDataForProduct=Barcode information of product %s :
BarCodeDataForThirdparty=Barcode information of thirdparty %s :
-BarcodeStickersMask=xxx
-
+ResetBarcodeForAllRecords=Define barcode value for all records (this will also reset barcode value already defined with new values)
+PriceByCustomer=Price by customer
+PriceCatalogue=Catalogue Price
+PricingRule=Pricing Rules
+AddCustomerPrice=Add price by customers
+ForceUpdateChildPriceSoc=Set same price on customer subsidiaries
+PriceByCustomerLog=Price by customer log
\ No newline at end of file
diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang
index eb2364cfc4f..d4a501e76a8 100644
--- a/htdocs/langs/es_ES/admin.lang
+++ b/htdocs/langs/es_ES/admin.lang
@@ -287,7 +287,7 @@ CurrentVersion=Versión actual de Dolibarr
CallUpdatePage=Llamar a la página de actualización de la estructura y datos de la base de datos %s.
LastStableVersion=Última versión estable disponible
GenericMaskCodes=Puede introducir cualquier máscara numérica. En esta máscara, puede utilizar las siguientes etiquetas:{000000} corresponde a un número que se incrementa en cada uno de %s. Introduzca tantos ceros como longitud desee mostrar. El contador se completará a partir de ceros por la izquierda con el fin de tener tantos ceros como la máscara. {000000+000} b> Igual que el anterior, con una compensación correspondiente al número a la derecha del signo + se aplica a partir del primer %s. {000000@x} igual que el anterior, pero el contador se restablece a cero cuando se llega a x meses (x entre 1 y 12). Si esta opción se utiliza y x es de 2 o superior, entonces la secuencia {yy}{mm} o {yyyy}{mm} también es necesaria. {dd} dÃas (01 a 31). {mm} mes (01 a 12). {yy} , {yyyy} ou {y} año en 2, 4 ó 1 cifra.
-# GenericMaskCodes2={cccc} the client code{cccc000} the client code on n characters is followed by a client's ref counter without offset and zeroized with the global counter.{tttt} The code of company type on n characters (see dictionary-company types).
+GenericMaskCodes2={cccc} el código de cliente en n caracteres{cccc000} el código de cliente en n caracteres es seguido por un contador propio al cliente sin offset, completado con ceros hasta completar la máscara, y volviendo a cero al mismo tiempo que el contador global.{tttt} El código del tipo de la empresa en n caracteres (ver diccionarios-tipos de empresas).
GenericMaskCodes3=Cualquier otro carácter en la máscara se quedará sin cambios. No se permiten espacios
GenericMaskCodes4a=Ejemplo en la 99 ª %s del tercero La Empresa realizada el 31/03/2007:
GenericMaskCodes4b=Ejemplo sobre un tercero creado el 31/03/2007:
diff --git a/htdocs/langs/es_ES/bills.lang b/htdocs/langs/es_ES/bills.lang
index 02b72f87d30..bfcd2875271 100644
--- a/htdocs/langs/es_ES/bills.lang
+++ b/htdocs/langs/es_ES/bills.lang
@@ -359,7 +359,7 @@ IntracommunityVATNumber=Número de IVA intracomunitario
PaymentByChequeOrderedTo=Pago mediante cheque nominativo a %s enviado a
PaymentByChequeOrderedToShort=Pago mediante cheque nominativo a
SendTo=enviado a
-PaymentByTransferOnThisBankAccount=Pago mediante trasferencia sobre la cuenta bancaria siguiente
+PaymentByTransferOnThisBankAccount=Pago mediante transferencia a la cuenta bancaria siguiente
VATIsNotUsedForInvoice=* IVA no aplicable art-293B del CGI
LawApplicationPart1=Por aplicación de la ley 80.335 de 12/05/80
LawApplicationPart2=las mercancÃas permanecen en propiedad de
diff --git a/htdocs/langs/es_ES/exports.lang b/htdocs/langs/es_ES/exports.lang
index 644ddaf34f9..8724ae4695e 100644
--- a/htdocs/langs/es_ES/exports.lang
+++ b/htdocs/langs/es_ES/exports.lang
@@ -102,14 +102,14 @@ NbOfLinesImported=Número de lÃneas correctamente importadas: %s .
DataComeFromNoWhere=El valor a insertar no corresponde a ningún campo del archivo origen.
DataComeFromFileFieldNb=El valor a insertar se corresponde al campo número %s del archivo origen.
DataComeFromIdFoundFromRef=El valor dado por el campo %s del archivo origen será utilizado para encontrar el ID del objeto padre a usar (el objeto %s con la referencia del archivo origen debe existir en Dolibarr).
-# DataComeFromIdFoundFromCodeId=Code that comes from field number %s of source file will be used to find id of parent object to use (So the code from source file must exists into dictionary %s ). Note that if you know id, you can also use it into source file instead of code. Import should work in both cases.
+DataComeFromIdFoundFromCodeId=El código del campo número %s del archivo de origen se utilizará para encontrar el id del objeto padre a usar (el código del archivo de origen debe existir en el diccionario %s ). Tenga en cuenta que si conoce el id, puede usarlo en lugar del código en el archivo de origen. La importación funcionará en los 2 casos.
DataIsInsertedInto=Los datos del archivo de origen se insertarán en el siguiente campo:
DataIDSourceIsInsertedInto=El ID del objeto padre encontrado a partir del dato origen, se insertará en el siguiente campo:
DataCodeIDSourceIsInsertedInto=El id de la lÃnea padre encontrada a partir del código, se insertará en el siguiente campo:
SourceRequired=Datos de origen obligatorios
SourceExample=Ejemplo de datos de origen posibles
ExampleAnyRefFoundIntoElement=Todas las referencias encontradas para los elementos %s
-# ExampleAnyCodeOrIdFoundIntoDictionary=Any code (or id) found into dictionary %s
+ExampleAnyCodeOrIdFoundIntoDictionary=Cualquier código (o identificador) encontrado en el diccionario %s
CSVFormatDesc=Archivo con formato Valores separados por coma (.csv). Es un fichero con formato de texto en el que los campos son separados por el carácter [ %s ]. Si el separador se encuentra en el contenido de un campo, El campo debe de estar acotado por el carácter [ %s ]. El carácter de escape para incluir un carácter de entorno en un dato es [ %s ].
Excel95FormatDesc=Archivo con formato Excel (.xls) Este es el formato nativo de Excel 95 (BIFF5).
Excel2007FormatDesc=Archivo con formato Excel (.xlsx) Este es el formato nativo de Excel 2007 (SpreadsheetML).
diff --git a/htdocs/langs/es_ES/products.lang b/htdocs/langs/es_ES/products.lang
index e078d6f09a3..9ea7de651c9 100644
--- a/htdocs/langs/es_ES/products.lang
+++ b/htdocs/langs/es_ES/products.lang
@@ -173,8 +173,8 @@ CustomCode=Código aduanero
CountryOrigin=PaÃs de origen
HiddenIntoCombo=Oculto en las listas
Nature=Naturaleza
-ProductCodeModel=Modelo de código de producto
-ServiceCodeModel=Modelo de código de servicio
+ProductCodeModel=Modelo de ref. de producto
+ServiceCodeModel=Modelo de ref. de servicio
AddThisProductCard=Crear ficha producto
HelpAddThisProductCard=Esta opción permite crear o clonar una ficha de producto en caso de que no exista
AddThisServiceCard=Crear ficha servicio
diff --git a/htdocs/langs/es_ES/stocks.lang b/htdocs/langs/es_ES/stocks.lang
index 7bd294aea08..638b3faed6c 100644
--- a/htdocs/langs/es_ES/stocks.lang
+++ b/htdocs/langs/es_ES/stocks.lang
@@ -94,14 +94,20 @@ DesiredStock=Stock deseado
StockToBuy=A pedir
Replenishment=Reaprovisionamiento
ReplenishmentOrders=Ordenes de reaprovisionamiento
-UseVirtualStock=Usar stock virtual en lugar de stock fÃsico
+VirtualDiffersFromPhysical=De acuerdo con las opciones de incremento/decremento de stock, el stock fÃsico y el stock virtual (fÃsico + pedidos actuales) puede diferir
+UseVirtualStockByDefault=Usar stock virtual por defecto, en lugar de stock fÃsico, para la funcionalidad de aprovisionamiento
+UseVirtualStock=Usar stock virtual
+UsePhysicalStock=Usar stock fÃsico
+CurentSelectionMode=Modo de selección actual
+CurentlyUsingVirtualStock=Stock virtual
+CurentlyUsingPhysicalStock=Stock fÃsico
RuleForStockReplenishment=Regla para el reaprovisionamiento de stock
SelectProductWithNotNullQty=Seleccie al menos un producto con una cantidad distinta de cero y un proveedor
AlertOnly= Sólo alertas
WarehouseForStockDecrease=Para el decremento de stock se usará el almacén %s
WarehouseForStockIncrease=Para el incremento de stock se usará el almacén %s
ForThisWarehouse=Para este almacén
-ReplenishmentStatusDesc=Este listado le permite ver productos con un stock inferior a la cantidad mÃnima deseada (o valor de alerta si el checkbok "Sólo alertas" está activado) y le sugiere crear los pedidos a proveedores para completar la diferencia.
+ReplenishmentStatusDesc=Esta es la lista de todos los productos con un stock menor que el stock deseado (o menor que el valor de alerta si el checkbox "sólo alertas" está marcado) y que sugiere crear pedidos de proveedor para rellenar la diferencia.
ReplenishmentOrdersDesc=Este es el listado de pedidos a proveedores en curso
Replenishments=Reaprovisionamiento
NbOfProductBeforePeriod=Cantidad del producto %s en stock antes del periodo seleccionado (< %s)
diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang
index d8c8c3e76d8..474e1e95873 100644
--- a/htdocs/langs/fr_FR/products.lang
+++ b/htdocs/langs/fr_FR/products.lang
@@ -217,4 +217,9 @@ DefinitionOfBarCodeForThirdpartyNotComplete=Définition du type ou valeure du co
BarCodeDataForProduct=Information de code barre du produit %s :
BarCodeDataForThirdparty=Information de code barre du tiers %s :
BarcodeStickersMask=xxx
-
+PriceByCustomer=Prix par clients
+PriceCatalogue=Prix unique
+PricingRule=Régles de prix
+AddCustomerPrice=Ajouter un prix par client
+ForceUpdateChildPriceSoc=Mettre le même prix pour les filliales
+PriceByCustomerLog=Historique prix par client
\ No newline at end of file
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index aaea6a2fd18..4d5cc811e85 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -42,6 +42,17 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e
$action = GETPOST('action','alpha');
$value = GETPOST('value','alpha');
+// Pricing Rules
+$select_pricing_rules=array(
+'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'),
+'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'),
+'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer')
+);
+if ($conf->global->MAIN_FEATURES_LEVEL==2) {
+ $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity');
+ $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES'] = $langs->trans('MultiPricesAbility') . '+' . $langs->trans('PriceByQuantity');
+}
+
/*
* Actions
@@ -96,12 +107,33 @@ else if ($action == 'multiprix_num')
{
$res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", $value,'chaine',0,'',$conf->entity);
}
-if ($action == 'multiprix')
+if ($action == 'pricingrule')
{
- $multiprix = GETPOST('activate_multiprix','alpha');
+ $princingrules = GETPOST('princingrule','alpha');
+ foreach ($select_pricing_rules as $rule=>$label) {
- $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity);
- $res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity);
+ if ($rule==$princingrules) {
+ if ( $princingrules =='PRODUCT_PRICE_UNIQ') {
+ $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0,'chaine',0,'',$conf->entity);
+ $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0,'chaine',0,'',$conf->entity);
+ $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0,'chaine',0,'',$conf->entity);
+ } else {
+ $multirule=explode('&',$princingrules);
+ if (is_array($multirule) && count($multirule)>0) {
+ foreach($multirule as $rulesselected) {
+ $res = dolibarr_set_const($db, $rulesselected, 1,'chaine',0,'',$conf->entity);
+ }
+ } else {
+ $res = dolibarr_set_const($db, $rule, 1,'chaine',0,'',$conf->entity);
+ }
+ }
+ } else {
+ if (strpos($rule,'&')===false) {
+ $res = dolibarr_set_const($db, $rule, 0,'chaine',0,'',$conf->entity);
+ }
+ }
+
+ }
}
else if ($action == 'sousproduits')
{
@@ -278,15 +310,20 @@ print ' '."\n";
* Formulaire parametres divers
*/
-// multiprix activation/desactivation
+
$var=!$var;
print '