Merge branch '8.0' of github.com:Dolibarr/dolibarr into FIX_credit_note_used_on_list
This commit is contained in:
commit
7ae6472e36
BIN
dev/resources/iso-normes/Accountancy-format_Ebp_txt.pdf
Normal file
BIN
dev/resources/iso-normes/Accountancy-format_Ebp_txt.pdf
Normal file
Binary file not shown.
@ -651,8 +651,8 @@ if ($action == 'create')
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
$total_debit = price2num($total_debit);
|
||||
$total_credit = price2num($total_credit);
|
||||
$total_debit = price2num($total_debit, 'MT');
|
||||
$total_credit = price2num($total_credit, 'MT');
|
||||
|
||||
if ($total_debit != $total_credit)
|
||||
{
|
||||
|
||||
@ -517,14 +517,19 @@ class AccountancyExport
|
||||
print $line->id . $separator;
|
||||
print $date . $separator;
|
||||
print $line->code_journal . $separator;
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print substr(length_accountg($line->numero_compte),0,2) . $separator;
|
||||
|
||||
if (empty($line->subledger_account)) {
|
||||
print $line->numero_compte . $separator;
|
||||
} else {
|
||||
print $line->subledger_account . $separator;
|
||||
}
|
||||
//print substr(length_accountg($line->numero_compte),0,2) . $separator;
|
||||
print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $separator;
|
||||
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$separator;
|
||||
print price2num($line->montant).$separator;
|
||||
print $line->sens.$separator;
|
||||
print $date . $separator;
|
||||
print 'EUR';
|
||||
//print 'EUR';
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ print '</tr>'."\n";
|
||||
|
||||
|
||||
// AGENDA REMINDER EMAIL
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL == 2)
|
||||
{
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).'</td>'."\n";
|
||||
@ -208,7 +208,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0)
|
||||
}
|
||||
|
||||
// AGENDA REMINDER BROWSER
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL == 2)
|
||||
{
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
|
||||
|
||||
@ -377,38 +377,43 @@ if ($object->id > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Relative discounts (Discounts-Drawbacks-Rebates)
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans("CustomerRelativeDiscountShort");
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->societe->creer && !$user->societe_id > 0)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td><td>'.($object->remise_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>':'').'</td>';
|
||||
print '</tr>';
|
||||
$isCustomer = ($object->client == 1 || $object->client == 3);
|
||||
|
||||
// Absolute discounts (Discounts-Drawbacks-Rebates)
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding">';
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("CustomerAbsoluteDiscountShort");
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->societe->creer && !$user->societe_id > 0)
|
||||
// Relative discounts (Discounts-Drawbacks-Rebates)
|
||||
if ($isCustomer)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans("CustomerRelativeDiscountShort");
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->societe->creer && !$user->societe_id > 0)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td><td>'.($object->remise_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>':'').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Absolute discounts (Discounts-Drawbacks-Rebates)
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding">';
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("CustomerAbsoluteDiscountShort");
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->societe->creer && !$user->societe_id > 0)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$amount_discount=$object->getAvailableDiscounts();
|
||||
if ($amount_discount < 0) dol_print_error($db,$object->error);
|
||||
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
|
||||
//else print $langs->trans("DiscountNone");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$amount_discount=$object->getAvailableDiscounts();
|
||||
if ($amount_discount < 0) dol_print_error($db,$object->error);
|
||||
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
|
||||
//else print $langs->trans("DiscountNone");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Max outstanding bill
|
||||
if ($object->client)
|
||||
|
||||
@ -751,7 +751,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -1119,7 +1119,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
|
||||
@ -106,7 +106,7 @@ if ($socid > 0)
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
$isCustomer = $object->client == 1 || $object->client == 3;
|
||||
$isCustomer = ($object->client == 1 || $object->client == 3);
|
||||
$isSupplier = $object->fournisseur == 1;
|
||||
|
||||
print '<form method="POST" action="remise.php?id='.$object->id.'">';
|
||||
@ -122,7 +122,7 @@ if ($socid > 0)
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
if(! $isCustomer && ! $isSupplier) {
|
||||
if (! $isCustomer && ! $isSupplier) {
|
||||
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -136,13 +136,13 @@ if ($socid > 0)
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
if($isCustomer) {
|
||||
if ($isCustomer) {
|
||||
// Customer discount
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
|
||||
}
|
||||
|
||||
if($isSupplier) {
|
||||
if ($isSupplier) {
|
||||
// Supplier discount
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
|
||||
@ -155,21 +155,28 @@ if ($socid > 0)
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
if($isCustomer && ! $isSupplier) {
|
||||
print '<input type="hidden" name="discount_type" value="0" />';
|
||||
}
|
||||
|
||||
if(! $isCustomer && $isSupplier) {
|
||||
print '<input type="hidden" name="discount_type" value="1" />';
|
||||
}
|
||||
/*if (! ($isCustomer && $isSupplier))
|
||||
{
|
||||
if ($isCustomer && ! $isSupplier) {
|
||||
print '<input type="hidden" name="discount_type" value="0" />';
|
||||
}
|
||||
if (! $isCustomer && $isSupplier) {
|
||||
print '<input type="hidden" name="discount_type" value="1" />';
|
||||
}
|
||||
}*/
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
if($isCustomer && $isSupplier) {
|
||||
if ($isCustomer || $isSupplier)
|
||||
{
|
||||
// Discount type
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
|
||||
print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
|
||||
print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td><td>';
|
||||
if ($isCustomer) {
|
||||
print '<input type="radio" name="discount_type" id="discount_type_0" checked value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
|
||||
}
|
||||
if ($isSupplier) {
|
||||
print ' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer?'':' checked').' value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -662,7 +662,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -1023,7 +1023,7 @@ if (empty($reshook))
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield POST Data
|
||||
if (is_array($extralabelsline)) {
|
||||
foreach ($extralabelsline as $key => $value) {
|
||||
|
||||
@ -638,11 +638,12 @@ else
|
||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||
print '<td>';
|
||||
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$accountingjournal->fetch($object->fk_accountancy_journal);
|
||||
|
||||
print $accountingjournal->getNomUrl(0,1,1,'',1);
|
||||
if ($object->fk_accountancy_journal > 0) {
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$accountingjournal->fetch($object->fk_accountancy_journal);
|
||||
|
||||
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -1290,15 +1290,15 @@ if (empty($reshook))
|
||||
$qualified=1;
|
||||
if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option
|
||||
if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...)
|
||||
if ($qualified) $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
|
||||
if ($qualified){
|
||||
$totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
|
||||
$tva_tx = $lines[$i]->tva_tx;
|
||||
$amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($totalamount != 0) {
|
||||
if ($numlines > 0) $numlines = $numlines-1;
|
||||
$tva_tx = $lines[$numlines]->tva_tx;
|
||||
if (! empty($lines[$numlines]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$numlines]->vat_src_code.')';
|
||||
$amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100;
|
||||
} else {
|
||||
if($totalamount == 0) {
|
||||
$amountdeposit[0] = 0;
|
||||
}
|
||||
} else {
|
||||
@ -1309,9 +1309,10 @@ if (empty($reshook))
|
||||
|
||||
$amount_ttc_diff = $amountdeposit[0];
|
||||
}
|
||||
|
||||
foreach ($amountdeposit as $tva => $amount)
|
||||
{
|
||||
if (empty($amount)) continue;
|
||||
|
||||
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
|
||||
$descline = $langs->trans('Deposit');
|
||||
//$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
|
||||
@ -1320,6 +1321,7 @@ if (empty($reshook))
|
||||
} elseif ($typeamount=='variable') {
|
||||
$descline.= ' ('. $valuedeposit.'%)';
|
||||
}
|
||||
|
||||
$descline.= ' - '.$srcobject->ref;
|
||||
$result = $object->addline(
|
||||
$descline,
|
||||
@ -1682,7 +1684,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -2089,7 +2091,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
|
||||
@ -1605,7 +1605,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").",";
|
||||
$sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).",";
|
||||
$sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).",";
|
||||
$sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter));
|
||||
$sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final));
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -453,7 +453,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline))
|
||||
{
|
||||
@ -776,7 +776,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
|
||||
$objectline = new FactureLigneRec($db);
|
||||
if ($objectline->fetch(GETPOST('lineid')))
|
||||
|
||||
@ -372,161 +372,156 @@ if (! is_array($x_coll) || ! is_array($x_paye))
|
||||
$subtot_coll_total_ht = 0;
|
||||
$subtot_coll_vat = 0;
|
||||
|
||||
if (is_array($x_both[$thirdparty_id]['coll']['detail']))
|
||||
{
|
||||
if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) {
|
||||
|
||||
// VAT Rate
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">';
|
||||
if (is_numeric($thirdparty_id))
|
||||
{
|
||||
$company_static->fetch($thirdparty_id);
|
||||
print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpid = preg_replace('/userid_/','',$thirdparty_id);
|
||||
$user_static->fetch($tmpid);
|
||||
print $langs->trans("User").': '.$user_static->getNomUrl(1);
|
||||
}
|
||||
print '</td><td colspan="'.($span+1).'"></td>';
|
||||
print '</tr>'."\n";
|
||||
if (is_array($x_both[$thirdparty_id]['coll']['detail'])) {
|
||||
|
||||
foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) {
|
||||
// Define type
|
||||
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
|
||||
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
// VAT Rate
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">';
|
||||
if (is_numeric($thirdparty_id)) {
|
||||
$company_static->fetch($thirdparty_id);
|
||||
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
|
||||
} else {
|
||||
$tmpid = preg_replace('/userid_/', '', $thirdparty_id);
|
||||
$user_static->fetch($tmpid);
|
||||
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
|
||||
}
|
||||
print '</td><td colspan="' . ($span + 1) . '"></td>';
|
||||
print '</tr>' . "\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
else print '<td></td>';
|
||||
|
||||
// Rate
|
||||
print '<td align="right">' . $fields['drate'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
{
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
|
||||
foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) {
|
||||
// Define type
|
||||
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
|
||||
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type = 1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">' . $fields['link'] . '</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
|
||||
print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
print '<td></td>';
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
||||
if ($reg[1]=='DEPOSIT') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1]=='CREDIT_NOTE') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
|
||||
// Rate
|
||||
print '<td align="right">' . $fields['drate'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid']) {
|
||||
$product_static->id = $fields['pid'];
|
||||
$product_static->ref = $fields['pref'];
|
||||
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
|
||||
}
|
||||
} else {
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'), 'service');
|
||||
} else {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
$text = img_object($langs->trans('Product'), 'product');
|
||||
}
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
|
||||
if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
|
||||
if ($reg[1] == 'DEPOSIT') {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1] == 'CREDIT_NOTE') {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
|
||||
} else {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
|
||||
}
|
||||
}
|
||||
print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax != 1)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'], $fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax != 1)
|
||||
{
|
||||
// Total HT
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc'])) {
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice = 1;
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
||||
$payment_static->id = $fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) {
|
||||
print $langs->trans("NA");
|
||||
} else {
|
||||
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
|
||||
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'], 'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$payment_static->id=$fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
|
||||
{
|
||||
print $langs->trans("NA");
|
||||
} else {
|
||||
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'],'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht, 'MT'), 1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat, 'MT'), 1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_coll_total_ht += $temp_ht;
|
||||
$subtot_coll_vat += $temp_vat;
|
||||
$x_coll_sum += $temp_vat;
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_coll_total_ht += $temp_ht;
|
||||
$subtot_coll_vat += $temp_vat;
|
||||
$x_coll_sum += $temp_vat;
|
||||
}
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">' . $langs->trans("Total") . ':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">' . price(price2num($subtot_coll_total_ht, 'MT')) . '</td>';
|
||||
print '<td class="nowrap" align="right">' . price(price2num($subtot_coll_vat, 'MT')) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
||||
@ -567,161 +562,153 @@ if (! is_array($x_coll) || ! is_array($x_paye))
|
||||
$subtot_paye_total_ht = 0;
|
||||
$subtot_paye_vat = 0;
|
||||
|
||||
if (is_array($x_both[$thirdparty_id]['paye']['detail']))
|
||||
{
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">';
|
||||
if (is_numeric($thirdparty_id))
|
||||
{
|
||||
$company_static->fetch($thirdparty_id);
|
||||
print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpid = preg_replace('/userid_/','',$thirdparty_id);
|
||||
$user_static->fetch($tmpid);
|
||||
print $langs->trans("User").': '.$user_static->getNomUrl(1);
|
||||
}
|
||||
print '<td colspan="'.($span+1).'"></td>';
|
||||
print '</tr>'."\n";
|
||||
if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) {
|
||||
|
||||
foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index=>$fields) {
|
||||
// Define type
|
||||
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
|
||||
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
if (is_array($x_both[$thirdparty_id]['paye']['detail'])) {
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">';
|
||||
if (is_numeric($thirdparty_id)) {
|
||||
$company_static->fetch($thirdparty_id);
|
||||
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
|
||||
} else {
|
||||
$tmpid = preg_replace('/userid_/', '', $thirdparty_id);
|
||||
$user_static->fetch($tmpid);
|
||||
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
|
||||
}
|
||||
print '<td colspan="' . ($span + 1) . '"></td>';
|
||||
print '</tr>' . "\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
else print '<td></td>';
|
||||
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
{
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
|
||||
foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) {
|
||||
// Define type
|
||||
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
|
||||
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type = 1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">' . $fields['link'] . '</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
|
||||
print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
print '<td></td>';
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
||||
if ($reg[1]=='DEPOSIT') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1]=='CREDIT_NOTE') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid']) {
|
||||
$product_static->id = $fields['pid'];
|
||||
$product_static->ref = $fields['pref'];
|
||||
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
|
||||
}
|
||||
} else {
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'), 'service');
|
||||
} else {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
$text = img_object($langs->trans('Product'), 'product');
|
||||
}
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
|
||||
if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
|
||||
if ($reg[1] == 'DEPOSIT') {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1] == 'CREDIT_NOTE') {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
|
||||
} else {
|
||||
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
|
||||
}
|
||||
}
|
||||
print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax != 1)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'], $fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax != 1)
|
||||
{
|
||||
// Total HT
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc'])) {
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice = 1;
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
||||
$paymentfourn_static->id = $fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
|
||||
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) {
|
||||
print $langs->trans("NA");
|
||||
} else {
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'], 'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT paid
|
||||
print '<td class="nowrap" align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$paymentfourn_static->id=$fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
|
||||
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
|
||||
{
|
||||
print $langs->trans("NA");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'],'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht, 'MT'), 1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat, 'MT'), 1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_paye_total_ht += $temp_ht;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
}
|
||||
|
||||
// VAT paid
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_paye_total_ht += $temp_ht;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
}
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">' . $langs->trans("Total") . ':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">' . price(price2num($subtot_paye_total_ht, 'MT')) . '</td>';
|
||||
print '<td class="nowrap" align="right">' . price(price2num($subtot_paye_vat, 'MT')) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_paye) == 0) { // Show a total line if nothing shown
|
||||
|
||||
@ -456,7 +456,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -737,7 +737,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
$objectline->array_options=$array_options;
|
||||
|
||||
// TODO verifier price_min si fk_product et multiprix
|
||||
|
||||
@ -892,6 +892,7 @@ class Contrat extends CommonObject
|
||||
$sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL");
|
||||
$sql.= ")";
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$error=0;
|
||||
@ -908,9 +909,8 @@ class Contrat extends CommonObject
|
||||
if ($result > 0)
|
||||
{
|
||||
$modCodeContract = new $module();
|
||||
|
||||
if (!empty($modCodeContract->code_auto)) {
|
||||
// Mise a jour ref
|
||||
if (! empty($modCodeContract->code_auto)) {
|
||||
// Force the ref to a draft value if numbering module is an automatic numbering
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -919,9 +919,6 @@ class Contrat extends CommonObject
|
||||
$this->ref="(PROV".$this->id.")";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->error='Failed to get PROV number';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1389,7 +1386,7 @@ class Contrat extends CommonObject
|
||||
if (empty($remise_percent)) $remise_percent=0;
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
|
||||
|
||||
|
||||
// Clean vat code
|
||||
$vat_src_code='';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
@ -1397,7 +1394,7 @@ class Contrat extends CommonObject
|
||||
$vat_src_code = $reg[1];
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
|
||||
@ -519,7 +519,7 @@ if ($massaction == 'confirm_createbills')
|
||||
else {
|
||||
// Load extrafields of order
|
||||
$cmd->fetch_optionals();
|
||||
|
||||
|
||||
$objecttmp->socid = $cmd->socid;
|
||||
$objecttmp->type = Facture::TYPE_STANDARD;
|
||||
$objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
|
||||
@ -577,6 +577,12 @@ if ($massaction == 'confirm_createbills')
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
// If we build one invoice for several order, we must put the invoice of order on the line
|
||||
if (! empty($createbills_onebythird))
|
||||
{
|
||||
$desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs));
|
||||
}
|
||||
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
|
||||
@ -4932,8 +4932,6 @@ abstract class CommonObject
|
||||
$new_array_options[$key] = price2num($this->array_options[$key]);
|
||||
break;
|
||||
case 'date':
|
||||
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'datetime':
|
||||
// If data is a string instead of a timestamp, we convert it
|
||||
if (! is_int($this->array_options[$key])) {
|
||||
@ -4981,8 +4979,9 @@ abstract class CommonObject
|
||||
$table_element = $this->table_element;
|
||||
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility
|
||||
|
||||
dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG);
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
|
||||
$this->db->query($sql_del);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
|
||||
@ -4993,6 +4992,17 @@ abstract class CommonObject
|
||||
if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator
|
||||
$sql.=",".$attributeKey;
|
||||
}
|
||||
// We must insert a default value for fields for other entities that are mandatory to avoid not null error
|
||||
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
|
||||
{
|
||||
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
|
||||
{
|
||||
if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
|
||||
{
|
||||
$sql.=",".$tmpkey;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= ") VALUES (".$this->id;
|
||||
|
||||
foreach($new_array_options as $key => $value)
|
||||
@ -5011,10 +5021,23 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
// We must insert a default value for fields for other entities that are mandatory to avoid not null error
|
||||
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
|
||||
{
|
||||
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
|
||||
{
|
||||
if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
|
||||
{
|
||||
if (in_array($tmpval, array('int', 'double'))) $sql.=", 0";
|
||||
else $sql.=", ''";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql.=")";
|
||||
|
||||
dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
|
||||
@ -747,7 +747,7 @@ class ExtraFields
|
||||
* @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
|
||||
* @return array Array of attributes keys+label for all extra fields.
|
||||
*/
|
||||
function fetch_name_optionals_label($elementtype,$forceload=false)
|
||||
function fetch_name_optionals_label($elementtype, $forceload=false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -783,8 +783,8 @@ class ExtraFields
|
||||
|
||||
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
|
||||
$sql.= " WHERE entity IN (0,".$conf->entity.")";
|
||||
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element
|
||||
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
|
||||
if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element
|
||||
$sql.= " ORDER BY pos";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
@ -794,6 +794,16 @@ class ExtraFields
|
||||
{
|
||||
while ($tab = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($tab->entity != 0 && $tab->entity != $conf->entity)
|
||||
{
|
||||
// This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value
|
||||
if ($tab->fieldrequired && is_null($tab->fielddefault))
|
||||
{
|
||||
$this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label']
|
||||
if ($tab->type != 'separate')
|
||||
{
|
||||
@ -1515,7 +1525,7 @@ class ExtraFields
|
||||
}
|
||||
elseif ($type == 'phone')
|
||||
{
|
||||
$value=dol_print_phone($value, '', 0, 0, '', ' ', 1);
|
||||
$value=dol_print_phone($value, '', 0, 0, '', ' ', 'phone');
|
||||
}
|
||||
elseif ($type == 'price')
|
||||
{
|
||||
|
||||
@ -3324,7 +3324,10 @@ class Form
|
||||
$langs->load('bills');
|
||||
|
||||
$opt = '<option value ="" selected></option>';
|
||||
$sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1';
|
||||
$sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc';
|
||||
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture';
|
||||
$sql.= ' WHERE entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND situation_counter>=1';
|
||||
$sql.= ' ORDER by situation_cycle_ref, situation_counter desc';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
@ -4517,7 +4520,7 @@ class Form
|
||||
|
||||
$out='';
|
||||
$out.= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
if ($useempty) $out .= '<option value=""></option>';
|
||||
if ($useempty) $out .= '<option value=""> </option>';
|
||||
// If company current currency not in table, we add it into list. Should always be available.
|
||||
if (! in_array($conf->currency, $TCurrency))
|
||||
{
|
||||
|
||||
@ -835,7 +835,7 @@ class DoliDBMysqli extends DoliDB
|
||||
if ($field_desc['default'] != '')
|
||||
{
|
||||
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
|
||||
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
|
||||
elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::DDLUpdateField ".$sql,LOG_DEBUG);
|
||||
|
||||
@ -1138,7 +1138,7 @@ class DoliDBPgsql extends DoliDB
|
||||
if ($field_desc['default'] != '')
|
||||
{
|
||||
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
|
||||
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
|
||||
elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
|
||||
}
|
||||
|
||||
dol_syslog($sql,LOG_DEBUG);
|
||||
|
||||
@ -177,7 +177,7 @@ function dol_verifyHash($chain, $hash, $type='0')
|
||||
* @param Canvas $objcanvas Object canvas
|
||||
* @param int $isdraft 1=The object with id=$objectid is a draft
|
||||
* @return int Always 1, die process if not allowed
|
||||
* @see dol_check_secure_access_document
|
||||
* @see dol_check_secure_access_document()
|
||||
*/
|
||||
function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null, $isdraft=0)
|
||||
{
|
||||
@ -431,7 +431,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
|
||||
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
|
||||
* @return bool True if user has access, False otherwise
|
||||
* @see restrictedArea
|
||||
* @see restrictedArea()
|
||||
*/
|
||||
function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid')
|
||||
{
|
||||
@ -451,13 +451,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
if ($feature == 'project') $feature='projet';
|
||||
if ($feature == 'task') $feature='projet_task';
|
||||
|
||||
$check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company)
|
||||
$check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource','expensereport'); // Test on entity only (Objects with no link to company)
|
||||
$checksoc = array('societe'); // Test for societe object
|
||||
$checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
|
||||
$checkproject = array('projet','project'); // Test for project object
|
||||
$checktask = array('projet_task');
|
||||
$nocheck = array('barcode','stock'); // No test
|
||||
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
|
||||
//$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
|
||||
|
||||
// If dbtablename not defined, we use same name for table than module name
|
||||
if (empty($dbtablename))
|
||||
|
||||
@ -80,7 +80,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
|
||||
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
|
||||
|
||||
// By default, we used MD5
|
||||
if (! in_array($cryptType,array('md5'))) $cryptType='md5';
|
||||
if (! in_array($cryptType, array('md5'))) $cryptType='md5';
|
||||
// Check crypted password according to crypt algorithm
|
||||
if ($cryptType == 'md5')
|
||||
{
|
||||
@ -109,8 +109,9 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'");
|
||||
sleep(2); // Anti brut force protection
|
||||
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType);
|
||||
//dol_syslog("passclear=".$passclear." passtyped=".$passtyped." passcrypted=".$passcrypted);
|
||||
sleep(2); // Anti brut force protection
|
||||
$langs->load('main');
|
||||
$langs->load('errors');
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
|
||||
|
||||
@ -888,6 +888,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$err = 0;
|
||||
|
||||
$sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
|
||||
$sql.= " AND entity IN (0, ".$conf->entity.")";
|
||||
@ -914,6 +916,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$err = 0;
|
||||
|
||||
$sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
|
||||
$sql.= " AND entity IN (0, ".$conf->entity.")";
|
||||
|
||||
@ -188,8 +188,8 @@ class MailingTargets // This can't be abstract as it is used for some method
|
||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// Si erreur autre que doublon
|
||||
dol_syslog($this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog($this->db->error().' : '.$targetarray['email']);
|
||||
$this->error=$this->db->error().' : '.$targetarray['email'];
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -179,7 +179,9 @@ class mailing_xinputfile extends MailingTargets
|
||||
{
|
||||
$i++;
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email);
|
||||
$msg = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email);
|
||||
if (!empty($msg)) $this->error = $msg;
|
||||
else $this->error = 'ErrorFoundBadEmailInFile '.$i.' '.$cpt.' '.$email; // We experience case where $langs->trans return an empty string.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ class modAgenda extends DolibarrModules
|
||||
$this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
|
||||
'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
|
||||
'ac.durationp'=>"Duree",
|
||||
'cac.libelle'=>"List:c_actioncomm:libelle:id",
|
||||
'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
|
||||
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
|
||||
'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
|
||||
's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text');
|
||||
@ -417,7 +417,7 @@ class modAgenda extends DolibarrModules
|
||||
$this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
|
||||
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)';
|
||||
if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
|
||||
$this->export_sql_end[$r] .=' ORDER BY ac.datep';
|
||||
$this->export_sql_order[$r] .=' ORDER BY ac.datep';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -260,15 +260,17 @@ else {
|
||||
if ($senderissupplier != 2)
|
||||
{
|
||||
$ajaxoptions=array(
|
||||
'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key
|
||||
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
|
||||
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo)
|
||||
'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
|
||||
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
|
||||
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo)
|
||||
);
|
||||
$alsoproductwithnosupplierprice=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ajaxoptions = array();
|
||||
$ajaxoptions = array(
|
||||
'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key
|
||||
);
|
||||
$alsoproductwithnosupplierprice=1;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
|
||||
|
||||
$hookmanager->initHooks(array('ordershipmentcard'));
|
||||
|
||||
$id=GETPOST('id','int'); // id of order
|
||||
$ref= GETPOST('ref','alpha');
|
||||
$action=GETPOST('action','alpha');
|
||||
@ -613,6 +615,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= " cd.qty,";
|
||||
$sql.= ' cd.date_start,';
|
||||
$sql.= ' cd.date_end,';
|
||||
$sql.= ' cd.special_code,';
|
||||
$sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
@ -648,164 +651,169 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$parameters = array('i' => $i, 'line' => $objp, 'num' => $num);
|
||||
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
// Show product and description
|
||||
$type=isset($objp->type)?$objp->type:$objp->product_type;
|
||||
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($objp->date_start)) $type=1;
|
||||
if (! empty($objp->date_end)) $type=1;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Product label
|
||||
if ($objp->fk_product > 0)
|
||||
if(empty($reshook))
|
||||
{
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
// Show product and description
|
||||
$type=isset($objp->type)?$objp->type:$objp->product_type;
|
||||
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($objp->date_start)) $type=1;
|
||||
if (! empty($objp->date_end)) $type=1;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Product label
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->id = $objp->fk_product;
|
||||
$prod->entity = $objp->entity;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->id = $objp->fk_product;
|
||||
$prod->entity = $objp->entity;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
|
||||
}
|
||||
else
|
||||
$label = (! empty($objp->label)?$objp->label:$objp->product_label);
|
||||
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Show product and description
|
||||
$product_static->type=$type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->entity = $objp->entity;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'<br>';
|
||||
$description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
|
||||
|
||||
// Add description in form
|
||||
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
$label = (! empty($objp->label)?$objp->label:$objp->product_label);
|
||||
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Show product and description
|
||||
$product_static->type=$type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->entity = $objp->entity;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'<br>';
|
||||
$description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
|
||||
|
||||
// Add description in form
|
||||
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print "<td>";
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
|
||||
if (! empty($objp->label)) {
|
||||
$text.= ' <strong>'.$objp->label.'</strong>';
|
||||
print $form->textwithtooltip($text,$objp->description,3,'','',$i);
|
||||
} else {
|
||||
print $text.' '.nl2br($objp->description);
|
||||
}
|
||||
|
||||
// Show range
|
||||
print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>";
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
// Qty ordered
|
||||
print '<td align="center">' . $objp->qty . '</td>';
|
||||
|
||||
if (! empty($objp->label)) {
|
||||
$text.= ' <strong>'.$objp->label.'</strong>';
|
||||
print $form->textwithtooltip($text,$objp->description,3,'','',$i);
|
||||
} else {
|
||||
print $text.' '.nl2br($objp->description);
|
||||
}
|
||||
|
||||
// Show range
|
||||
print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
// Qty ordered
|
||||
print '<td align="center">' . $objp->qty . '</td>';
|
||||
|
||||
// Qty already shipped
|
||||
$qtyProdCom=$objp->qty;
|
||||
print '<td align="center">';
|
||||
// Nb of sending products for this line of order
|
||||
$qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
|
||||
print $qtyAlreadyShipped;
|
||||
print '</td>';
|
||||
|
||||
// Qty remains to ship
|
||||
print '<td align="center">';
|
||||
if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
$toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
|
||||
$toBeShippedTotal += $toBeShipped[$objp->fk_product];
|
||||
print $toBeShipped[$objp->fk_product];
|
||||
}
|
||||
else
|
||||
{
|
||||
print '0 ('.$langs->trans("Service").')';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
$product->load_stock('warehouseopen');
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
|
||||
{
|
||||
// Qty already shipped
|
||||
$qtyProdCom=$objp->qty;
|
||||
print '<td align="center">';
|
||||
print $product->stock_reel;
|
||||
if ($product->stock_reel < $toBeShipped[$objp->fk_product])
|
||||
// Nb of sending products for this line of order
|
||||
$qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
|
||||
print $qtyAlreadyShipped;
|
||||
print '</td>';
|
||||
|
||||
// Qty remains to ship
|
||||
print '<td align="center">';
|
||||
if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
$toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
|
||||
$toBeShippedTotal += $toBeShipped[$objp->fk_product];
|
||||
print $toBeShipped[$objp->fk_product];
|
||||
}
|
||||
else
|
||||
{
|
||||
print '0 ('.$langs->trans("Service").')';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
// Show subproducts lines
|
||||
if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
{
|
||||
// Set tree of subproducts in product->sousprods
|
||||
$product->get_sousproduits_arbo();
|
||||
//var_dump($product->sousprods);exit;
|
||||
|
||||
// Define a new tree with quantiies recalculated
|
||||
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
|
||||
//var_dump($prods_arbo);
|
||||
if (count($prods_arbo) > 0)
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
foreach($prods_arbo as $key => $value)
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
$product->load_stock('warehouseopen');
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $product->stock_reel;
|
||||
if ($product->stock_reel < $toBeShipped[$objp->fk_product])
|
||||
{
|
||||
$img='';
|
||||
if ($value['stock'] < $value['stock_alert'])
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
// Show subproducts lines
|
||||
if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
{
|
||||
// Set tree of subproducts in product->sousprods
|
||||
$product->get_sousproduits_arbo();
|
||||
//var_dump($product->sousprods);exit;
|
||||
|
||||
// Define a new tree with quantiies recalculated
|
||||
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
|
||||
//var_dump($prods_arbo);
|
||||
if (count($prods_arbo) > 0)
|
||||
{
|
||||
foreach($prods_arbo as $key => $value)
|
||||
{
|
||||
$img=img_warning($langs->trans("StockTooLow"));
|
||||
$img='';
|
||||
if ($value['stock'] < $value['stock_alert'])
|
||||
{
|
||||
$img=img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '<tr class="oddeven"><td> -> <a href="'.DOL_URL_ROOT."/product/card.php?id=".$value['id'].'">'.$value['fullpath'].'</a> ('.$value['nb'].')</td>';
|
||||
print '<td align="center"> '.$value['nb_total'].'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">'.$value['stock'].' '.$img.'</td></tr>'."\n";
|
||||
}
|
||||
print '<tr class="oddeven"><td> -> <a href="'.DOL_URL_ROOT."/product/card.php?id=".$value['id'].'">'.$value['fullpath'].'</a> ('.$value['nb'].')</td>';
|
||||
print '<td align="center"> '.$value['nb_total'].'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">'.$value['stock'].' '.$img.'</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
@ -886,7 +894,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print $langs->trans("WarehouseSource");
|
||||
//print '</td>';
|
||||
//print '<td>';
|
||||
print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
|
||||
print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
|
||||
if (count($formproduct->cache_warehouses) <= 0)
|
||||
{
|
||||
print ' '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>';
|
||||
|
||||
@ -759,6 +759,7 @@ if ($step == 3 && $datatoexport)
|
||||
|
||||
// un formulaire en plus pour recuperer les filtres
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?step=4&action=submitFormField&datatoexport='.$datatoexport.'" name="FilterField" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Entities").'</td>';
|
||||
|
||||
@ -362,7 +362,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
|
||||
$result = $object->addline(
|
||||
$user,
|
||||
@ -509,7 +509,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
|
||||
$result=$object->addline(
|
||||
$user,
|
||||
@ -622,7 +622,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
$objectline->array_options = $array_options;
|
||||
|
||||
$result = $objectline->update($user);
|
||||
|
||||
@ -1501,9 +1501,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param int $origin_id id origin document
|
||||
* @param double $pu_ht_devise Amount in currency
|
||||
* @param string $ref_supplier Supplier ref
|
||||
* @param string $special_code Special code
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='')
|
||||
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='', $special_code='')
|
||||
{
|
||||
global $langs, $mysoc, $conf;
|
||||
|
||||
@ -1646,30 +1647,34 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->line->fk_facture_fourn=$this->id;
|
||||
//$this->line->label=$label; // deprecated
|
||||
$this->line->desc=$desc;
|
||||
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
|
||||
$this->line->ref_supplier=$ref_supplier;
|
||||
|
||||
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
|
||||
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
|
||||
$this->line->vat_src_code=$vat_src_code;
|
||||
$this->line->tva_tx=$txtva;
|
||||
$this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
|
||||
$this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
|
||||
$this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
|
||||
$this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva);
|
||||
$this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1);
|
||||
$this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2);
|
||||
$this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
|
||||
|
||||
$this->line->fk_product=$fk_product;
|
||||
$this->line->product_type=$type;
|
||||
$this->line->remise_percent=$remise_percent;
|
||||
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->date_start=$date_start;
|
||||
$this->line->date_end=$date_end;
|
||||
$this->line->ventil=$ventil;
|
||||
$this->line->rang=$rang;
|
||||
$this->line->info_bits=$info_bits;
|
||||
$this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
|
||||
$this->line->total_tva= $total_tva;
|
||||
$this->line->total_localtax1=$total_localtax1;
|
||||
$this->line->total_localtax2=$total_localtax2;
|
||||
$this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
|
||||
$this->line->special_code=$this->special_code;
|
||||
|
||||
$this->line->special_code=((string) $special_code != '' ? $special_code : $this->special_code);
|
||||
$this->line->fk_parent_line=$this->fk_parent_line;
|
||||
$this->line->origin=$this->origin;
|
||||
$this->line->origin_id=$origin_id;
|
||||
@ -1837,11 +1842,11 @@ class FactureFournisseur extends CommonInvoice
|
||||
$line->localtax2_tx = $txlocaltax2;
|
||||
$line->localtax1_type = $localtaxes_type[0];
|
||||
$line->localtax2_type = $localtaxes_type[2];
|
||||
$line->total_ht = $total_ht;
|
||||
$line->total_tva = $total_tva;
|
||||
$line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht);
|
||||
$line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva);
|
||||
$line->total_localtax1 = $total_localtax1;
|
||||
$line->total_localtax2 = $total_localtax2;
|
||||
$line->total_ttc = $total_ttc;
|
||||
$line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
|
||||
$line->fk_product = $idproduct;
|
||||
$line->product_type = $product_type;
|
||||
$line->info_bits = $info_bits;
|
||||
|
||||
@ -308,7 +308,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -614,7 +614,7 @@ if (empty($reshook))
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield POST Data
|
||||
if (is_array($extralabelsline)) {
|
||||
foreach ($extralabelsline as $key => $value) {
|
||||
|
||||
@ -499,7 +499,7 @@ if ($id > 0 || ! empty($ref)) {
|
||||
$sql .= " WHERE l.fk_commande = " . $object->id;
|
||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
$sql .= " AND l.product_type = 0";
|
||||
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
||||
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
||||
$sql .= " ORDER BY p.ref, p.label";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -482,7 +482,7 @@ $sql.= " typent.code as typent_code,";
|
||||
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,";
|
||||
$sql.= ' cf.date_creation as date_creation, cf.tms as date_update,';
|
||||
$sql.= " p.rowid as project_id, p.ref as project_ref,";
|
||||
$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
|
||||
$sql.= " u.firstname, u.lastname, u.photo, u.login";
|
||||
// Add fields from extrafields
|
||||
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
|
||||
@ -988,6 +988,7 @@ if ($resql)
|
||||
{
|
||||
$projectstatic->id=$obj->project_id;
|
||||
$projectstatic->ref=$obj->project_ref;
|
||||
$projectstatic->title=$obj->project_title;
|
||||
print '<td>';
|
||||
if ($obj->project_id > 0) print $projectstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
@ -927,7 +927,10 @@ if (empty($reshook))
|
||||
0,
|
||||
$lines[$i]->array_options,
|
||||
$lines[$i]->fk_unit,
|
||||
$lines[$i]->id
|
||||
$lines[$i]->id,
|
||||
0,
|
||||
'',
|
||||
$lines[$i]->special_code
|
||||
);
|
||||
|
||||
if ($result < 0)
|
||||
@ -1053,7 +1056,7 @@ if (empty($reshook))
|
||||
// Extrafields Lines
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield POST Data
|
||||
if (is_array($extralabelsline)) {
|
||||
foreach ($extralabelsline as $key => $value) {
|
||||
@ -1129,7 +1132,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
|
||||
@ -390,7 +390,7 @@ if (! $search_all)
|
||||
$sql.= " typent.code,";
|
||||
$sql.= " state.code_departement, state.nom,";
|
||||
$sql.= ' country.code,';
|
||||
$sql.= " p.rowid, p.ref";
|
||||
$sql.= " p.rowid, p.ref, p.title";
|
||||
|
||||
foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
|
||||
{
|
||||
|
||||
@ -71,7 +71,7 @@ if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="p.rowid";
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
|
||||
$amounts = array();array();
|
||||
$amounts = array();
|
||||
$amountsresttopay=array();
|
||||
$addwarning=0;
|
||||
|
||||
@ -251,6 +251,22 @@ if (empty($reshook))
|
||||
|
||||
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
|
||||
// Clean parameters amount if payment is for a credit note
|
||||
if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE)
|
||||
{
|
||||
foreach ($amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
$newvalue = price2num($value,'MT');
|
||||
$amounts[$key] = -$newvalue;
|
||||
}
|
||||
|
||||
foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
$newvalue = price2num($value,'MT');
|
||||
$multicurrency_amounts[$key] = -$newvalue;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
@ -431,6 +447,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<input type="hidden" name="facid" value="'.$facid.'">';
|
||||
print '<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$obj->socid.'">';
|
||||
print '<input type="hidden" name="type" id="invoice_type" value="'.$object->type.'">';
|
||||
print '<input type="hidden" name="societe" value="'.$obj->name.'">';
|
||||
|
||||
dol_fiche_head(null);
|
||||
@ -600,14 +617,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
||||
print '<td align="right">'.price($sign * $objp->total_ttc).'</td>';
|
||||
|
||||
print '<td align="right">'.price($objp->am);
|
||||
print '<td align="right">'.price($sign * $objp->am);
|
||||
if ($creditnotes) print '+'.price($creditnotes);
|
||||
if ($deposits) print '+'.price($deposits);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">'.price($remaintopay).'</td>';
|
||||
print '<td align="right">'.price($sign * $remaintopay).'</td>';
|
||||
|
||||
// Amount
|
||||
print '<td align="center">';
|
||||
|
||||
@ -26,6 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement_fourn.class.p
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
$langs->loadLangs(array('bills'));
|
||||
|
||||
// Security check
|
||||
$socid='';
|
||||
if (! empty($user->societe_id)) $socid=$user->societe_id;
|
||||
|
||||
@ -326,7 +326,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
|
||||
{
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE u.rowid = x.fk_user_author";
|
||||
$sql.= " AND x.entity = ".$conf->entity;
|
||||
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')';
|
||||
|
||||
@ -346,7 +346,7 @@ else
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="ref" value="'.$object->ref.'">';
|
||||
|
||||
dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), 0, 'sending');
|
||||
dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'sending');
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression
|
||||
@ -607,87 +607,85 @@ else
|
||||
$var=true;
|
||||
while ($i < $num_prod)
|
||||
{
|
||||
$parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod);
|
||||
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if(empty($reshook)) {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
if ($object->lines[$i]->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($object->lines[$i]->fk_product);
|
||||
print '<tr class="oddeven">';
|
||||
if ($object->lines[$i]->fk_product > 0) {
|
||||
$product = new Product($db);
|
||||
$product->fetch($object->lines[$i]->fk_product);
|
||||
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
// Define output language
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
|
||||
if (empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
|
||||
} else
|
||||
$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
|
||||
|
||||
print '<td>';
|
||||
|
||||
// Affiche ligne produit
|
||||
$text = '<a href="' . DOL_URL_ROOT . '/product/card.php?id=' . $object->lines[$i]->fk_product . '">';
|
||||
if ($object->lines[$i]->fk_product_type == 1) $text .= img_object($langs->trans('ShowService'), 'service');
|
||||
else $text .= img_object($langs->trans('ShowProduct'), 'product');
|
||||
$text .= ' ' . $object->lines[$i]->product_ref . '</a>';
|
||||
$text .= ' - ' . $label;
|
||||
$description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description));
|
||||
//print $description;
|
||||
print $form->textwithtooltip($text, $description, 3, '', '', $i);
|
||||
print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
|
||||
print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->description) : '';
|
||||
}
|
||||
} else {
|
||||
print "<td>";
|
||||
if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service');
|
||||
else $text = img_object($langs->trans('Product'), 'product');
|
||||
|
||||
if (!empty($object->lines[$i]->label)) {
|
||||
$text .= ' <strong>' . $object->lines[$i]->label . '</strong>';
|
||||
print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i);
|
||||
} else {
|
||||
print $text . ' ' . nl2br($object->lines[$i]->description);
|
||||
}
|
||||
|
||||
$label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
|
||||
}
|
||||
else
|
||||
$label = ( ! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
|
||||
|
||||
print '<td>';
|
||||
|
||||
// Affiche ligne produit
|
||||
$text = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$object->lines[$i]->fk_product.'">';
|
||||
if ($object->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
||||
$text.= ' '.$object->lines[$i]->product_ref.'</a>';
|
||||
$text.= ' - '.$label;
|
||||
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->description));
|
||||
//print $description;
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
|
||||
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
print (! empty($object->lines[$i]->description) && $object->lines[$i]->description!=$object->lines[$i]->product_label)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->description):'';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>";
|
||||
if ($object->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
|
||||
if (! empty($object->lines[$i]->label)) {
|
||||
$text.= ' <strong>'.$object->lines[$i]->label.'</strong>';
|
||||
print $form->textwithtooltip($text,$object->lines[$i]->description,3,'','',$i);
|
||||
} else {
|
||||
print $text.' '.nl2br($object->lines[$i]->description);
|
||||
print_date_range($objp->date_start, $objp->date_end);
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="center">' . $object->lines[$i]->qty_asked . '</td>';
|
||||
print '<td align="center">' . $object->lines[$i]->qty_shipped . '</td>';
|
||||
|
||||
print '<td align="center">'.$object->lines[$i]->qty_asked.'</td>';
|
||||
print '<td align="center">'.$object->lines[$i]->qty_shipped.'</td>';
|
||||
print "</tr>";
|
||||
|
||||
print "</tr>";
|
||||
|
||||
//Display lines extrafields
|
||||
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
||||
$colspan=2;
|
||||
$mode = ($object->statut == 0) ? 'edit' : 'view';
|
||||
$line = new LivraisonLigne($db);
|
||||
$line->fetch_optionals($object->lines[$i]->id);
|
||||
if ($action = 'create_delivery') {
|
||||
$srcLine = new ExpeditionLigne($db);
|
||||
$expeditionLineExtrafields = new Extrafields($db);
|
||||
$expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
|
||||
$srcLine->fetch_optionals($expedition->lines[$i]->id);
|
||||
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
|
||||
//Display lines extrafields
|
||||
if (is_array($extralabelslines) && count($extralabelslines) > 0) {
|
||||
$colspan = 2;
|
||||
$mode = ($object->statut == 0) ? 'edit' : 'view';
|
||||
$line = new LivraisonLigne($db);
|
||||
$line->fetch_optionals($object->lines[$i]->id);
|
||||
if ($action = 'create_delivery') {
|
||||
$srcLine = new ExpeditionLigne($db);
|
||||
$expeditionLineExtrafields = new Extrafields($db);
|
||||
$expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
|
||||
$srcLine->fetch_optionals($expedition->lines[$i]->id);
|
||||
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
|
||||
}
|
||||
print '<tr class="oddeven">';
|
||||
print $line->showOptionals($extrafieldsline, $mode, array('style' => $bc[$var], 'colspan' => $colspan), $i);
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr class="oddeven">';
|
||||
print $line->showOptionals($extrafieldsline, $mode, array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
@ -96,6 +96,9 @@ function marges_prepare_head()
|
||||
$head[$h][2] = 'checkMargins';
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'margins','remove');
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'margins');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@ -3584,8 +3584,10 @@ class Product extends CommonObject
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
$label.= '<br><b>' . $langs->trans('ProductAccountancySellCode') . ':</b> '. length_accountg($this->accountancy_code_sell);
|
||||
$label.= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> '. length_accountg($this->accountancy_code_sell_export);
|
||||
$label.= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> '. length_accountg($this->accountancy_code_sell_intra);
|
||||
if(!empty($conf->global->MAIN_FEATURES_LEVEL)) {
|
||||
$label.= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> '. length_accountg($this->accountancy_code_sell_export);
|
||||
$label.= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> '. length_accountg($this->accountancy_code_sell_intra);
|
||||
}
|
||||
}
|
||||
if (! empty($conf->accounting->enabled) && $this->status_buy)
|
||||
{
|
||||
|
||||
@ -159,9 +159,13 @@ $arrayfields=array(
|
||||
//'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
|
||||
'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled) && ! empty($conf->service->enabled))),
|
||||
'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))),
|
||||
'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)),
|
||||
'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))),
|
||||
'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))),
|
||||
'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))),
|
||||
'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled))),
|
||||
'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)),
|
||||
'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
|
||||
'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
|
||||
'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
|
||||
@ -261,7 +265,7 @@ else
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
|
||||
$sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
|
||||
$sql.= ' p.fk_product_type, p.duration, p.weight, p.length, p.surface, p.volume, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
|
||||
$sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,';
|
||||
$sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,';
|
||||
$sql.= ' MIN(pfp.unitprice) as minsellprice';
|
||||
@ -316,7 +320,7 @@ $parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
|
||||
$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
|
||||
$sql.= " p.fk_product_type, p.duration, p.weight, p.length, p.surface, p.volume, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
|
||||
$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp';
|
||||
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) $sql .= ', pac.rowid';
|
||||
// Add fields from extrafields
|
||||
@ -552,9 +556,32 @@ if ($resql)
|
||||
if (! empty($arrayfields['p.duration']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
// Weight
|
||||
if (! empty($arrayfields['p.weight']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Length
|
||||
if (! empty($arrayfields['p.length']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Surface
|
||||
if (! empty($arrayfields['p.surface']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Volume
|
||||
if (! empty($arrayfields['p.volume']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Sell price
|
||||
if (! empty($arrayfields['p.sellprice']['checked']))
|
||||
{
|
||||
@ -650,6 +677,10 @@ if ($resql)
|
||||
if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||
@ -746,7 +777,7 @@ if ($resql)
|
||||
// Label
|
||||
if (! empty($arrayfields['p.label']['checked']))
|
||||
{
|
||||
print '<td class="tdoverflowmax200">'.dol_trunc($obj->label,40).'</td>';
|
||||
print '<td class="tdoverflowmax200">'.dol_trunc($obj->label, 40).'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -781,6 +812,39 @@ if ($resql)
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Weight
|
||||
if (! empty($arrayfields['p.weight']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $obj->weight;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Length
|
||||
if (! empty($arrayfields['p.length']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $obj->length;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Surface
|
||||
if (! empty($arrayfields['p.surface']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $obj->surface;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Volume
|
||||
if (! empty($arrayfields['p.volume']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $obj->volume;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Sell price
|
||||
if (! empty($arrayfields['p.sellprice']['checked']))
|
||||
{
|
||||
|
||||
@ -509,7 +509,7 @@ else
|
||||
print '<td>'.$objp->produit.'</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
$valtoshow=price2num($objp->value, 'MS');
|
||||
$valtoshow=price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function
|
||||
print empty($valtoshow)?'0':$valtoshow;
|
||||
print '</td>';
|
||||
$totalunit+=$objp->value;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013-2016 Laurent Destaileur <ely@users.sourceforge.net>
|
||||
* Copyright (C) 2013-2018 Laurent Destaileur <ely@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
|
||||
@ -42,6 +42,9 @@ if ($user->societe_id) {
|
||||
}
|
||||
$result=restrictedArea($user,'produit|service');
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('stockreplenishlist'));
|
||||
|
||||
//checks if a product has been ordered
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
@ -86,6 +89,9 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
||||
$usevirtualstock=0;
|
||||
if ($mode == 'virtual') $usevirtualstock=1;
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -295,6 +301,12 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre
|
||||
}
|
||||
$sql.= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,';
|
||||
$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique';
|
||||
|
||||
// Add fields from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p';
|
||||
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s';
|
||||
$sql.= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))';
|
||||
@ -304,6 +316,12 @@ if ($fk_supplier > 0) {
|
||||
if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')';
|
||||
}
|
||||
|
||||
// Add fields from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListJoin',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= ' WHERE p.entity IN (' . getEntity('product') . ')';
|
||||
if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
|
||||
// if the type is not 1, we show all products (type = 0,2,3)
|
||||
@ -384,6 +402,11 @@ if ($usevirtualstock)
|
||||
}
|
||||
}
|
||||
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
|
||||
@ -447,9 +470,15 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE))
|
||||
print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
|
||||
print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1);
|
||||
print '</div>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) print $hookmanager->resPrint;
|
||||
|
||||
print '<div class="inline-block valignmiddle">';
|
||||
print '<input class="button" type="submit" name="valid" value="'.$langs->trans('ToFilter').'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) {
|
||||
@ -531,6 +560,12 @@ print '<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&
|
||||
print '<td class="liste_titre" align="right">' . $langs->trans('IncludeAlsoDraftOrders') . ' <input type="checkbox" id="draftorder" name="draftorder" ' . (!empty($draftchecked)?$draftchecked:'') . '></td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
|
||||
// Fields from hook
|
||||
$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
@ -548,6 +583,12 @@ print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $pa
|
||||
print_liste_field_titre('Ordered', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('StockToBuy', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('SupplierRef', $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
|
||||
|
||||
// Hook fields
|
||||
$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < ($limit ? min($num, $limit) : $num))
|
||||
@ -674,10 +715,20 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
// Supplier
|
||||
print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).'</td>';
|
||||
|
||||
// Fields from hook
|
||||
$parameters=array( 'objp'=>$objp);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$parameters=array('sql'=>$sql);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('projects','users','companies'));
|
||||
|
||||
$hookmanager->initHooks(array('timesheetperdaycard'));
|
||||
|
||||
$action=GETPOST('action','aZ09');
|
||||
$mode=GETPOST("mode",'alpha');
|
||||
$id=GETPOST('id','int');
|
||||
|
||||
@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('projects','users','companies'));
|
||||
|
||||
$hookmanager->initHooks(array('timesheetperweekcard'));
|
||||
|
||||
$action=GETPOST('action','aZ09');
|
||||
$mode=GETPOST("mode",'alpha');
|
||||
$id=GETPOST('id','int');
|
||||
|
||||
@ -338,7 +338,7 @@ class Project extends CommonObject
|
||||
if (file_exists($olddir))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$res=dol_move($olddir, $newdir);
|
||||
$res=@rename($olddir, $newdir);
|
||||
if (! $res)
|
||||
{
|
||||
$langs->load("errors");
|
||||
@ -723,10 +723,10 @@ class Project extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete tasks with no children first, then task with children recursively
|
||||
*
|
||||
*
|
||||
* @param User $user User
|
||||
* @return int <0 if KO, 1 if OK
|
||||
*/
|
||||
@ -754,7 +754,7 @@ class Project extends CommonObject
|
||||
{
|
||||
if (count($this->lines)) $this->deleteTasks($this->lines);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -709,8 +709,8 @@ while ($i < min($num,$limit))
|
||||
// Title
|
||||
if (! empty($arrayfields['p.title']['checked']))
|
||||
{
|
||||
print '<td class="tdoverflowmax100">';
|
||||
print dol_trunc($obj->title,80);
|
||||
print '<td class="tdoverflowmax200">';
|
||||
print dol_trunc($obj->title, 80);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -973,7 +973,7 @@ else
|
||||
$object->idprof6 = GETPOST('idprof6', 'alpha');
|
||||
$object->typent_id = GETPOST('typent_id', 'int');
|
||||
$object->effectif_id = GETPOST('effectif_id', 'int');
|
||||
$object->civility_id = GETPOST('civility_id', 'int');
|
||||
$object->civility_id = GETPOST('civility_id', 'alpha');
|
||||
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'int');
|
||||
$object->status = GETPOST('status', 'int');
|
||||
|
||||
@ -550,7 +550,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -814,7 +814,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
|
||||
@ -1783,6 +1783,12 @@ foreach($mainmenuusedarray as $val)
|
||||
$found=1;
|
||||
break;
|
||||
}
|
||||
else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité
|
||||
{
|
||||
$url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1);
|
||||
$found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Img file not found
|
||||
if (! $found)
|
||||
|
||||
@ -855,7 +855,7 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
print '<td>';
|
||||
print $form->selectyesno('admin',GETPOST('admin'),1);
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity)
|
||||
{
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
@ -1992,7 +1992,7 @@ else
|
||||
{
|
||||
print $form->selectyesno('admin',$object->admin,1);
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity)
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -30,9 +31,9 @@ $langs->load("other");
|
||||
$var = false;
|
||||
$id = GETPOST('id', 'int');
|
||||
$valueid = GETPOST('valueid', 'int');
|
||||
$ref = GETPOST('ref');
|
||||
$weight_impact = (float) GETPOST('weight_impact');
|
||||
$price_impact = (float) GETPOST('price_impact');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$weight_impact = GETPOST('weight_impact', 'alpha');
|
||||
$price_impact = GETPOST('price_impact', 'alpha');
|
||||
$price_impact_percent = (bool) GETPOST('price_impact_percent');
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user