Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
root 2020-01-02 13:56:09 +01:00
commit 93b894bf92
53 changed files with 887 additions and 751 deletions

View File

@ -152,6 +152,7 @@ NEW: #4301
For Developers or integrators: For Developers or integrators:
NEW: Compatible with PHP 7.4
NEW: Code for extrafields uses the new array $extrafields->attributes NEW: Code for extrafields uses the new array $extrafields->attributes
NEW: Can set a filter on object linked in modulebuilder. NEW: Can set a filter on object linked in modulebuilder.
NEW: Can defined a position of numbering submodules for thirdparties NEW: Can defined a position of numbering submodules for thirdparties

View File

@ -357,25 +357,25 @@ class BookKeeping extends CommonObject
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'".$this->db->idate($this->doc_date)."'"; $sql .= "'".$this->db->idate($this->doc_date)."'";
$sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'");
$sql .= ",'".$this->db->escape($this->doc_type)."'"; $sql .= ", '".$this->db->escape($this->doc_type)."'";
$sql .= ",'".$this->db->escape($this->doc_ref)."'"; $sql .= ", '".$this->db->escape($this->doc_ref)."'";
$sql .= ",".$this->fk_doc; $sql .= ", ".$this->fk_doc;
$sql .= ",".$this->fk_docdet; $sql .= ", ".$this->fk_docdet;
$sql .= ",'".$this->db->escape($this->thirdparty_code)."'"; $sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL");
$sql .= ",'".$this->db->escape($this->subledger_account)."'"; $sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL");
$sql .= ",'".$this->db->escape($this->subledger_label)."'"; $sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL");
$sql .= ",'".$this->db->escape($this->numero_compte)."'"; $sql .= ", '".$this->db->escape($this->numero_compte)."'";
$sql .= ",'".$this->db->escape($this->label_compte)."'"; $sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL");
$sql .= ",'".$this->db->escape($this->label_operation)."'"; $sql .= ", '".$this->db->escape($this->label_operation)."'";
$sql .= ",".$this->debit; $sql .= ", ".$this->debit;
$sql .= ",".$this->credit; $sql .= ", ".$this->credit;
$sql .= ",".$this->montant; $sql .= ", ".$this->montant;
$sql .= ",'".$this->db->escape($this->sens)."'"; $sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL");
$sql .= ",'".$this->db->escape($this->fk_user_author)."'"; $sql .= ", '".$this->db->escape($this->fk_user_author)."'";
$sql .= ",'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'";
$sql .= ",'".$this->db->escape($this->code_journal)."'"; $sql .= ", '".$this->db->escape($this->code_journal)."'";
$sql .= ",'".$this->db->escape($this->journal_label)."'"; $sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL");
$sql .= ",".$this->db->escape($this->piece_num); $sql .= ", ".$this->db->escape($this->piece_num);
$sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ")"; $sql .= ")";

View File

@ -142,14 +142,14 @@ $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
{ {
// Button off, click to enable // Button off, click to enable
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} }
else else
{ {
// Button on, click to disable // Button on, click to disable
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} }
@ -174,8 +174,8 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
$adht = new AdherentType($db); $adht = new AdherentType($db);
print '<tr class="oddeven drag" id="trforcetype"><td>'; print '<tr class="oddeven drag" id="trforcetype"><td>';
print $langs->trans("ForceMemberType"); print $langs->trans("ForceMemberType");
print '</td><td width="60" class="right">'; print '</td><td class="right">';
$listofval = array(-1 => $langs->trans("Undefined")); $listofval = array();
$listofval += $adht->liste_array(); $listofval += $adht->liste_array();
$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0);

View File

@ -691,14 +691,14 @@ if ($rowid > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
} }
print "</tr>\n"; print "</tr>\n";

View File

@ -825,12 +825,15 @@ if ($mode == 'common')
$warningmessage = ''; $warningmessage = '';
if (!empty($arrayofwarnings[$modName])) if (!empty($arrayofwarnings[$modName]))
{ {
print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n"; print '<!-- This module is a core module and it may have a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage)
{
if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry)))
{ {
$warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
} }
} }
}
if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext))
{ {
print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n"; print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";

View File

@ -1,129 +0,0 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2019 Maxime Kohlhaas <maxime@atm-consulting.fr>
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file bom/admin/setup.php
* \ingroup bom
* \brief Bom setup page.
*/
// Load Dolibarr environment
require '../../main.inc.php';
// Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once '../lib/bom.lib.php';
//require_once "../class/myclass.class.php";
// Translations
$langs->loadLangs(array("admin", "mrp"));
// Access control
if (!$user->admin) accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters = array(
'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
);
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
/*
* View
*/
$page_name = "BomSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom');
// Configuration header
$head = bomAdminPrepareHead();
dol_fiche_head($head, 'settings', '', -1, "bom");
// Setup page goes here
echo $langs->trans("BomSetupPage").'<br><br>';
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
}
print '</table>';
print '<br><div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
print '<br>';
}
else
{
if (!empty($arrayofparameters))
{
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
print '</td><td>'.$conf->global->$key.'</td></tr>';
}
print '</table>';
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}
else
{
print '<br>'.$langs->trans("NothingToSetup");
}
}
// Page end
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -48,9 +48,9 @@ $langs->loadLangs(array("main","bills"));
</script> </script>
<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p> <p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo GETPOST('facid', 'int'); ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
<br> <br>
<p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p> <p><a class="lien1" href="#" onclick="Javascript: popupTicket(<?php echo GETPOST('facid', 'int'); ?>,'<?php echo $langs->trans('PrintTicket') ?>'); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
</div> </div>
</div> </div>

View File

@ -514,9 +514,10 @@ class ActionComm extends CommonObject
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id");
// Now insert assignedusers // Now insert assigned users
if (!$error) if (!$error)
{ {
//dol_syslog(var_export($this->userassigned, true));
foreach ($this->userassigned as $key => $val) foreach ($this->userassigned as $key => $val)
{ {
if (!is_array($val)) // For backward compatibility when val=id if (!is_array($val)) // For backward compatibility when val=id
@ -524,6 +525,8 @@ class ActionComm extends CommonObject
$val = array('id'=>$val); $val = array('id'=>$val);
} }
if ($val['id'] > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")";
@ -531,17 +534,19 @@ class ActionComm extends CommonObject
if (!$resql) if (!$resql)
{ {
$error++; $error++;
dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR);
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
} }
//var_dump($sql);exit; //var_dump($sql);exit;
} }
} }
}
if (!$error) if (!$error)
{ {
if (!empty($this->socpeopleassigned)) if (!empty($this->socpeopleassigned))
{ {
foreach ($this->socpeopleassigned as $id => $Tab) foreach ($this->socpeopleassigned as $id => $val)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)";
@ -550,6 +555,7 @@ class ActionComm extends CommonObject
if (!$resql) if (!$resql)
{ {
$error++; $error++;
dol_syslog('Error to process socpeopleassigned: '.$this->db->lasterror(), LOG_ERR);
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
} }
} }
@ -558,8 +564,6 @@ class ActionComm extends CommonObject
if (!$error) if (!$error)
{ {
$action = 'create';
// Actions on extra fields // Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
@ -1721,6 +1725,13 @@ class ActionComm extends CommonObject
} }
$diff++; $diff++;
} }
$parameters=array('filters' => $filters, 'eventarray' => &$eventarray);
$reshook=$hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook
if ($reshook > 0)
{
$eventarray = $hookmanager->resArray;
}
} }
else else
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
@ -238,6 +238,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>'; print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
@ -261,6 +262,7 @@ print '<td><input name="amount" class="flat" type="text" size="6" value="'.dol_e
print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>'; print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>';
print "</table>"; print "</table>";
print '</div>';
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>'; print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>';

View File

@ -456,7 +456,7 @@ if ($id)
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent tableforfield">';
// Label // Label
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';

View File

@ -134,7 +134,7 @@ if ($object->id)
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';

View File

@ -780,6 +780,23 @@ if (empty($reshook))
} }
} }
// If some payments were already done, we change the amount to pay using same prorate
if (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) {
$alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded.
if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) {
$ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc);
foreach($amount_ht as $vatrate => $val) {
$amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU');
$amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU');
$amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU');
$multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU');
$multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU');
$multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU');
}
}
}
//var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit;
// Insert one discount by VAT rate category // Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
if ($object->type == Facture::TYPE_CREDIT_NOTE) if ($object->type == Facture::TYPE_CREDIT_NOTE)
@ -1520,7 +1537,7 @@ if (empty($reshook))
if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')';
// View third's localtaxes for NOW and do not use value from origin. // View third's localtaxes for NOW and do not use value from origin.
// TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? // TODO Is this really what we want ? Yes if source is template invoice but what if proposal or order ?
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
@ -5014,7 +5031,9 @@ elseif ($id > 0 || !empty($ref))
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a>'; print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a>';
} }
// For credit note // For credit note
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate
&& (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
) {
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReduc2")).'">'.$langs->trans('ConvertToReduc').'</a>'; print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReduc2")).'">'.$langs->trans('ConvertToReduc').'</a>';
} }
// For deposit invoice // For deposit invoice

View File

@ -327,28 +327,6 @@ class Paiement extends CommonObject
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit; //var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
/* Why this ? We can remove i think.
// If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing.
$mustwait=0;
$sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande";
$sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0";
...
$listofpayments=$invoice->getListOfPayments();
foreach($listofpayments as $paym)
{
// This payment on invoice $invoice might be the one we record or another one
if ($paym['type']=='PRE')
{
if (! empty($conf->prelevement->enabled))
{
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
}
}
}
*/
//Invoice types that are eligible for changing status to paid //Invoice types that are eligible for changing status to paid
$affected_types = array( $affected_types = array(
Facture::TYPE_STANDARD, Facture::TYPE_STANDARD,

View File

@ -351,7 +351,7 @@ class BonPrelevement extends CommonObject
if ($this->db->begin()) if ($this->db->begin())
{ {
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " SET statut = 1"; $sql .= " SET statut = ".self::STATUS_TRANSFERED;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -437,11 +437,11 @@ class BonPrelevement extends CommonObject
{ {
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons ";
$sql .= " SET fk_user_credit = ".$user->id; $sql .= " SET fk_user_credit = ".$user->id;
$sql .= ", statut = 2"; $sql .= ", statut = ".self::STATUS_CREDITED;
$sql .= ", date_credit = '".$this->db->idate($date)."'"; $sql .= ", date_credit = '".$this->db->idate($date)."'";
$sql .= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$sql .= " AND statut = 1"; $sql .= " AND statut = ".self::STATUS_TRANSFERED;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -483,7 +483,8 @@ class BonPrelevement extends CommonObject
$paiement->datepaye = $date; $paiement->datepaye = $date;
$paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice
$paiement->paiementid = 3; // $paiement->paiementid = 3; //
$paiement->num_paiement = $this->ref; // Set ref of direct debit note $paiement->num_payment = $this->ref; // Set ref of direct debit note
$paiement->num_paiement = $this->ref; // For bacward compatibility
$paiement->id_prelevement = $this->id; $paiement->id_prelevement = $this->id;
$paiement_id = $paiement->create($user); $paiement_id = $paiement->create($user);
@ -530,7 +531,7 @@ class BonPrelevement extends CommonObject
if ($error == 0) if ($error == 0)
{ {
$this->date_credit = $date; $this->date_credit = $date;
$this->statut = 1; $this->statut = self::STATUS_CREDITED;
$this->db->commit(); $this->db->commit();
return 0; return 0;

View File

@ -108,6 +108,10 @@ class ChargeSociales extends CommonObject
public $fk_project; public $fk_project;
const STATUS_UNPAID = 0;
const STATUS_PAID = 1;
/** /**
* Constructor * Constructor
* *
@ -495,43 +499,23 @@ class ChargeSociales extends CommonObject
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("customers","bills")); $langs->loadLangs(array("customers","bills"));
if ($mode == 0 || $mode == 1) if (empty($this->labelStatus) || empty($this->labelStatusShort))
{ {
if ($status == 0) return $langs->trans("Unpaid"); global $langs;
elseif ($status == 1) return $langs->trans("Paid"); //$langs->load("mymodule");
} $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid');
elseif ($mode == 2) $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid');
{ if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
}
elseif ($mode == 3)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 4)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
elseif ($mode == 5)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 6)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
} }
else return "Error, mode/status not found"; $statusType = 'status1';
if ($status == 0 && $alreadypaid > 0) $statusType = 'status3';
if ($status == 1) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }

View File

@ -107,7 +107,8 @@ abstract class CommonInvoice extends CommonObject
} }
/** /**
* Return amount of payments already done * Return amount of payments already done. This must include ONLY the record into the payment table.
* Payments dones using discounts, credit notes, etc are not included.
* *
* @param int $multicurrency Return multicurrency_amount instead of amount * @param int $multicurrency Return multicurrency_amount instead of amount
* @return int Amount of payment already done, <0 if KO * @return int Amount of payment already done, <0 if KO
@ -337,6 +338,51 @@ abstract class CommonInvoice extends CommonObject
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
//look for credit notes and discounts and deposits
$sql = '';
if ($this->element == 'facture' || $this->element == 'invoice')
{
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id;
$sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
}
elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id;
$sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
}
if ($sql) {
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($multicurrency) {
$retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref);
}
else {
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref);
}
$i++;
}
}
else
{
$this->error = $this->db->lasterror();
dol_print_error($this->db);
return array();
}
$this->db->free($resql);
}
return $retarray; return $retarray;
} }
else else

View File

@ -7494,7 +7494,7 @@ abstract class CommonObject
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
$keys = array(); $keys = array();
$values = array(); $values = array();
@ -7729,6 +7729,7 @@ abstract class CommonObject
if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now);
if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id;
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
$keys = array(); $keys = array();
$values = array(); $values = array();

View File

@ -546,7 +546,7 @@ class DiscountAbsolute
* Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended).
* *
* @param CommonInvoice $invoice Object invoice (customer of supplier) * @param CommonInvoice $invoice Object invoice (customer of supplier)
* @param int $multicurrency Return multicurrency_amount instead of amount * @param int $multicurrency 1=Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise * @return int <0 if KO, Sum of credit notes and deposits amount otherwise
*/ */
public function getSumDepositsUsed($invoice, $multicurrency = 0) public function getSumDepositsUsed($invoice, $multicurrency = 0)
@ -578,7 +578,7 @@ class DiscountAbsolute
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($multicurrency) return $obj->multicurrency_amount; if ($multicurrency == 1) return $obj->multicurrency_amount;
else return $obj->amount; else return $obj->amount;
} }
else else
@ -592,7 +592,7 @@ class DiscountAbsolute
* Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment
* *
* @param CommonInvoice $invoice Object invoice * @param CommonInvoice $invoice Object invoice
* @param int $multicurrency Return multicurrency_amount instead of amount * @param int $multicurrency 1=Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of credit notes and excess received amount otherwise * @return int <0 if KO, Sum of credit notes and excess received amount otherwise
*/ */
public function getSumCreditNotesUsed($invoice, $multicurrency = 0) public function getSumCreditNotesUsed($invoice, $multicurrency = 0)
@ -624,7 +624,7 @@ class DiscountAbsolute
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($multicurrency) return $obj->multicurrency_amount; if ($multicurrency == 1) return $obj->multicurrency_amount;
else return $obj->amount; else return $obj->amount;
} }
else else

View File

@ -109,8 +109,10 @@ class Interfaces
$handle = opendir($newdir); $handle = opendir($newdir);
if (is_resource($handle)) if (is_resource($handle))
{ {
$fullpathfiles = array();
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$reg=array();
if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg))
{ {
$part1 = $reg[1]; $part1 = $reg[1];
@ -274,6 +276,7 @@ class Interfaces
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$reg = array();
if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg))
{ {
if (preg_match('/\.back$/', $file)) continue; if (preg_match('/\.back$/', $file)) continue;

View File

@ -221,7 +221,7 @@ class Translate
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{ {
dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); dol_syslog("Error: ".get_class($this)."::load was called for domain=".$domain." but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
return -1; return -1;
} }
@ -428,7 +428,7 @@ class Translate
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{ {
dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); dol_syslog("Error: ".get_class($this)."::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
return -1; return -1;
} }

View File

@ -4677,6 +4677,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell
dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
$vatratecleaned = $vatrate; $vatratecleaned = $vatrate;
$reg = array();
if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)"
{ {
$vatratecleaned = trim($reg[1]); $vatratecleaned = trim($reg[1]);
@ -4921,13 +4922,14 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
// Search local taxes // Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql = "SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
if ($firstparamisid) $sql .= " WHERE t.rowid = ".(int) $vatrate; if ($firstparamisid) $sql .= " WHERE t.rowid = ".(int) $vatrate;
else else
{ {
$vatratecleaned = $vatrate; $vatratecleaned = $vatrate;
$vatratecode = ''; $vatratecode = '';
$reg = array();
if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)" if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)"
{ {
$vatratecleaned = $reg[1]; $vatratecleaned = $reg[1];
@ -4945,17 +4947,20 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$vateratestring = $obj->rate.($obj->code ? ' ('.$obj->code.')' : '');
if ($local == 1) if ($local == 1)
{ {
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); return array($obj->localtax1_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} }
elseif ($local == 2) elseif ($local == 2)
{ {
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); return array($obj->localtax2_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} }
else else
{ {
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); return array($obj->localtax1_type, get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} }
} }

View File

@ -1260,12 +1260,14 @@ class pdf_einstein extends ModelePDFCommandes
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -1393,12 +1393,14 @@ class pdf_eratosthene extends ModelePDFCommandes
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -162,7 +162,7 @@ class doc_generic_contract_odt extends ModelePDFContract
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
} }
// Add select to upload a new template file. TODO Copy this feature on other admin pages. // Add input to upload a new template file.
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; $texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte .= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; $texte .= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; $texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';

View File

@ -595,7 +595,7 @@ class pdf_crabe extends ModelePDFFactures
{ {
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxprogress, $curY); $pdf->SetXY($this->posxprogress, $curY);
$pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 3, $progress, 0, 'R'); $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
} }
// Total HT line // Total HT line
@ -1618,12 +1618,14 @@ class pdf_crabe extends ModelePDFFactures
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -1834,12 +1834,14 @@ class pdf_sponge extends ModelePDFFactures
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -99,7 +99,7 @@ class modCashDesk extends DolibarrModules
'type'=>'top', // This is a Top menu entry 'type'=>'top', // This is a Top menu entry
'titre'=>'PointOfSaleShort', 'titre'=>'PointOfSaleShort',
'mainmenu'=>'cashdesk', 'mainmenu'=>'cashdesk',
'url'=>'/cashdesk/index.php?user=__LOGIN__', 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__',
'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>900, 'position'=>900,
'enabled'=>'$conf->cashdesk->enabled', 'enabled'=>'$conf->cashdesk->enabled',

View File

@ -1467,12 +1467,14 @@ class pdf_azur extends ModelePDFPropales
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -1503,12 +1503,14 @@ class pdf_cyan extends ModelePDFPropales
{ {
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
$logodir = $conf->mycompany->dir_output;
if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{ {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} }
else { else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) if (is_readable($logo))
{ {

View File

@ -356,35 +356,36 @@ if ($nolinesbefore) {
<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"]) ?GETPOST("price_ht", 'alpha', 2) : ''); ?>"> <input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"]) ?GETPOST("price_ht", 'alpha', 2) : ''); ?>">
</td> </td>
<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { <?php
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecoluht_currency right"> <td class="nobottom linecoluht_currency right">
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"]) ?GETPOST("multicurrency_price_ht", 'alpha', 2) : ''); ?>"> <input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"]) ?GETPOST("multicurrency_price_ht", 'alpha', 2) : ''); ?>">
</td> </td>
<?php } <?php
}
if (!empty($inputalsopricewithtax)) { if (!empty($inputalsopricewithtax)) {
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecoluttc right"> <td class="nobottom linecoluttc right">
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"]) ?GETPOST("price_ttc", 'alpha', 2) : ''); ?>"> <input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"]) ?GETPOST("price_ttc", 'alpha', 2) : ''); ?>">
</td> </td>
<?php } <?php
}
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"]) ?GETPOST("qty", 'alpha', 2) : 1); ?>"> <td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"]) ?GETPOST("qty", 'alpha', 2) : 1); ?>">
</td> </td>
<?php <?php
if ($conf->global->PRODUCT_USE_UNITS) if (! empty($conf->global->PRODUCT_USE_UNITS)) {
{
$coldisplay++; $coldisplay++;
print '<td class="nobottom linecoluseunit left">'; print '<td class="nobottom linecoluseunit left">';
print $form->selectUnits($line->fk_unit, "units"); print $form->selectUnits($line->fk_unit, "units");
print '</td>'; print '</td>';
} }
$remise_percent = $buyer->remise_percent; $remise_percent = $buyer->remise_percent;
if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
{
$remise_percent = $seller->remise_supplier_percent; $remise_percent = $seller->remise_supplier_percent;
} }
$coldisplay++; $coldisplay++;
@ -397,8 +398,7 @@ if ($nolinesbefore) {
$coldisplay++; $coldisplay++;
print '<td></td>'; print '<td></td>';
} }
if (!empty($usemargins)) if (!empty($usemargins)) {
{
if (!empty($user->rights->margins->creer)) { if (!empty($user->rights->margins->creer)) {
$coldisplay++; $coldisplay++;
?> ?>
@ -434,14 +434,12 @@ if ($nolinesbefore) {
if (is_object($objectline)) { if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
} }
if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{ {
?> print '<tr id="trlinefordates" class="oddeven">'."\n";
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; }
<tr id="trlinefordates" <?php echo $bcnd[$var]; ?>> print '<td colspan="'.($coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1)).'">';
<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?>
<td colspan="<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1); ?>">
<?php
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
if (!empty($object->element) && $object->element == 'contrat') if (!empty($object->element) && $object->element == 'contrat')
@ -453,9 +451,9 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
} }
else else
{ {
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0);
echo ' '.$langs->trans('to').' '; print ' '.$langs->trans('to').' ';
print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0);
}; };
print '<script>'; print '<script>';
@ -477,13 +475,14 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
} }
print '</script>'; print '</script>';
print '</td>'; print '</td>';
print "</tr>\n"; print '</tr>'."\n";
} }
print "<script>\n";
print "<script>\n";
if (!empty($usemargins) && $user->rights->margins->creer) if (!empty($usemargins) && $user->rights->margins->creer)
{ {
?> ?>
/* Some js test when we click on button "Add" */ /* Some js test when we click on button "Add" */
jQuery(document).ready(function() { jQuery(document).ready(function() {
<?php <?php
@ -621,21 +620,22 @@ if (!empty($usemargins) && $user->rights->margins->creer)
/* When changing predefined product, we reload list of supplier prices required for margin combo */ /* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function() $("#idprod, #idprodfournprice").change(function()
{ {
console.log("#idprod, #idprodfournprice change triggered"); console.log("#idprod, #idprodfournprice change triggered this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
jQuery('#trlinefordates').show(); jQuery('#trlinefordates').show();
<?php <?php
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier))
{ {
?> ?>
// get the HT price for the product and display it // Get the HT price for the product and display it
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : <?php print $object->socid; ?> }, function(data) { $.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
jQuery("#price_ht").val(data.price_ht); { 'id': $(this).val(), 'socid' : <?php print $object->socid; ?> },
}, function(data) { jQuery("#price_ht").val(data.price_ht); },
'json'); 'json'
);
<?php <?php
} }
if (!empty($usemargins) && $user->rights->margins->creer) if (!empty($usemargins) && $user->rights->margins->creer)
@ -814,6 +814,8 @@ if (!empty($usemargins) && $user->rights->margins->creer)
jQuery('#trlinefordates, .divlinefordates').show(); jQuery('#trlinefordates, .divlinefordates').show();
} }
</script> <?php
<!-- END PHP TEMPLATE objectline_create.tpl.php --> print '</script>';
print "<!-- END PHP TEMPLATE objectline_create.tpl.php -->\n";

View File

@ -954,8 +954,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
} }
else else
{ {
$error ="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); $this->error="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors);
$this->error=$error;
$this->errors=$actioncomm->errors; $this->errors=$actioncomm->errors;
dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);

View File

@ -118,9 +118,6 @@ class InterfaceStripe
// Data and type of action are stored into $object and $action // Data and type of action are stored into $object and $action
global $langs, $db, $conf; global $langs, $db, $conf;
// Load translation files required by the page
$langs->loadLangs(array("members","other","users","mails"));
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
$stripe = new Stripe($db); $stripe = new Stripe($db);

View File

@ -1639,7 +1639,7 @@ class FactureFournisseur extends CommonInvoice
$result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc
if ($result > 0) if ($result > 0)
{ {
$pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice if (empty($pu)) $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
$ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice
// is remise percent not keyed but present for the product we add it // is remise percent not keyed but present for the product we add it
if ($remise_percent == 0 && $prod->remise_percent != 0) if ($remise_percent == 0 && $prod->remise_percent != 0)
@ -1691,6 +1691,7 @@ class FactureFournisseur extends CommonInvoice
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty);
// Clean vat code // Clean vat code
$reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg))
{ {

View File

@ -361,7 +361,7 @@ if (empty($reshook))
else else
{ {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$price_ht = ''; $price_ht = GETPOST('price_ht');
$tva_tx = ''; $tva_tx = '';
} }
@ -420,15 +420,14 @@ if (empty($reshook))
} }
} }
// Ecrase $pu par celui du produit if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
if (($prod_entry_mode != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
{ {
$productsupplier = new ProductFournisseur($db); $productsupplier = new ProductFournisseur($db);
$idprod = 0; $idprod = 0;
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
$reg = array();
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
{ {
$idprod = $reg[1]; $idprod = $reg[1];
@ -470,7 +469,22 @@ if (empty($reshook))
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type; $type = $productsupplier->type;
if ($price_ht != '' || $price_ht_devise != '') {
$price_base_type = 'HT';
$pu = price2num($price_ht, 'MU');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
} else {
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency
$pu = $productsupplier->fourn_pu;
$pu_ht_devise = 0;
} else {
$pu = $productsupplier->fourn_pu;
$pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice;
/*var_dump($pu);
var_dump($pu_ht_devise);exit;*/
}
}
$ref_supplier = $productsupplier->ref_supplier; $ref_supplier = $productsupplier->ref_supplier;
@ -480,7 +494,6 @@ if (empty($reshook))
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$pu = $productsupplier->fourn_pu;
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
$result = $object->addline( $result = $object->addline(
@ -503,7 +516,9 @@ if (empty($reshook))
$date_end, $date_end,
$array_options, $array_options,
$productsupplier->fk_unit, $productsupplier->fk_unit,
$productsupplier->fourn_multicurrency_unitprice $pu_ht_devise,
'',
0
); );
} }
if ($idprod == -99 || $idprod == 0) if ($idprod == -99 || $idprod == 0)
@ -2200,7 +2215,7 @@ elseif (!empty($object->id))
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
if (!empty($conf->multicurrency->enabled)) if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1)
{ {
// Multicurrency Amount HT // Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';

View File

@ -99,8 +99,11 @@ if (!empty($user->socid)) $socid = $user->socid;
$isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft);
$usercancreate = $user->rights->fournisseur->facture->creer;
$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php $permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
@ -402,7 +405,7 @@ if (empty($reshook))
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} }
elseif ($action == "setabsolutediscount" && $user->rights->fournisseur->facture->creer) elseif ($action == "setabsolutediscount" && $usercancreate)
{ {
// POST[remise_id] or POST[remise_id_for_payment] // POST[remise_id] or POST[remise_id_for_payment]
@ -460,7 +463,7 @@ if (empty($reshook))
} }
} }
// Convertir en reduc // Convertir en reduc
elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -472,12 +475,13 @@ if (empty($reshook))
$canconvert = 0; $canconvert = 0;
if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc)
if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc)
if ($canconvert) if ($canconvert)
{ {
$db->begin(); $db->begin();
$amount_ht = $amount_tva = $amount_ttc = array(); $amount_ht = $amount_tva = $amount_ttc = array();
$multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
// Loop on each vat rate // Loop on each vat rate
$i = 0; $i = 0;
@ -492,6 +496,20 @@ if (empty($reshook))
} }
} }
// If some payments were already done, we change the amount to pay using same prorate
if (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) {
$alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded.
if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) {
$ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc);
foreach($amount_ht as $vatrate => $val) {
$amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU');
$amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU');
$amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU');
}
}
}
//var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit;
// Insert one discount by VAT rate category // Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE)
@ -513,6 +531,7 @@ if (empty($reshook))
{ {
// If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT
// Total payments
$sql = 'SELECT SUM(pf.amount) as total_paiements'; $sql = 'SELECT SUM(pf.amount) as total_paiements';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')';
@ -526,7 +545,20 @@ if (empty($reshook))
$res = $db->fetch_object($resql); $res = $db->fetch_object($resql);
$total_paiements = $res->total_paiements; $total_paiements = $res->total_paiements;
$discount->amount_ht = $discount->amount_ttc = $total_paiements - $object->total_ttc; // Total credit note and deposit
$total_creditnote_and_deposit = 0;
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql .= " re.description, re.fk_invoice_supplier_source";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re";
$sql .= " WHERE fk_invoice_supplier = ".$object->id;
$resql = $db->query($sql);
if (!empty($resql)) {
while ($obj = $db->fetch_object($resql)) {
$total_creditnote_and_deposit += $obj->amount_ttc;
}
} else dol_print_error($db);
$discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc;
$discount->amount_tva = 0; $discount->amount_tva = 0;
$discount->tva_tx = 0; $discount->tva_tx = 0;
@ -600,7 +632,7 @@ if (empty($reshook))
} }
// Create // Create
elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) elseif ($action == 'add' && $usercancreate)
{ {
if ($socid > 0) $object->socid = GETPOST('socid', 'int'); if ($socid > 0) $object->socid = GETPOST('socid', 'int');
@ -632,7 +664,7 @@ if (empty($reshook))
if (!$error) { if (!$error) {
// This is a replacement invoice // This is a replacement invoice
$result = $object->fetch(GETPOST('fac_replacement'), 'int'); $result = $object->fetch(GETPOST('fac_replacement', 'int'));
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->ref = GETPOST('ref', 'nohtml'); $object->ref = GETPOST('ref', 'nohtml');
@ -1143,7 +1175,7 @@ if (empty($reshook))
else else
{ {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$price_ht = ''; $price_ht = GETPOST('price_ht');
$tva_tx = ''; $tva_tx = '';
} }
@ -1209,6 +1241,7 @@ if (empty($reshook))
$idprod = 0; $idprod = 0;
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
$reg = array();
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
{ {
$idprod = $reg[1]; $idprod = $reg[1];
@ -1250,7 +1283,20 @@ if (empty($reshook))
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type; $type = $productsupplier->type;
if ($price_ht != '' || $price_ht_devise != '') {
$price_base_type = 'HT';
$pu = price2num($price_ht, 'MU');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
} else {
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency
$pu = $productsupplier->fourn_pu;
$pu_ht_devise = 0;
} else {
$pu = $productsupplier->fourn_pu;
$pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice;
}
}
$ref_supplier = $productsupplier->ref_supplier; $ref_supplier = $productsupplier->ref_supplier;
@ -1260,7 +1306,6 @@ if (empty($reshook))
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$pu = $productsupplier->fourn_pu;
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
$result = $object->addline( $result = $object->addline(
@ -1283,8 +1328,9 @@ if (empty($reshook))
$array_options, $array_options,
$productsupplier->fk_unit, $productsupplier->fk_unit,
0, 0,
$productsupplier->fourn_multicurrency_unitprice, $pu_ht_devise,
$ref_supplier $ref_supplier,
''
); );
} }
if ($idprod == -99 || $idprod == 0) if ($idprod == -99 || $idprod == 0)
@ -3129,7 +3175,9 @@ else
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessPaidToReduc').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessPaidToReduc').'</a></div>';
} }
// For credit note // For credit note
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer
&& (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReducSupplier2")).'">'.$langs->trans('ConvertToReduc').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReducSupplier2")).'">'.$langs->trans('ConvertToReduc').'</a></div>';
} }
// For deposit invoice // For deposit invoice

View File

@ -180,7 +180,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
/*************************************************************************************** /***************************************************************************************
* *
* Migration des donnees * Migration of data
* *
***************************************************************************************/ ***************************************************************************************/
$db->begin(); $db->begin();
@ -553,6 +553,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print '</table>'; print '</table>';
$sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'";
$db->query($sql, 1);
// We always commit. // We always commit.
// Process is designed so we can run it several times whatever is situation. // Process is designed so we can run it several times whatever is situation.
$db->commit(); $db->commit();

View File

@ -61,7 +61,7 @@ Payment=Payment
PaymentBack=Payment back PaymentBack=Payment back
CustomerInvoicePaymentBack=Payment back CustomerInvoicePaymentBack=Payment back
Payments=Payments Payments=Payments
PaymentsBack=Payments back PaymentsBack=Refunds
paymentInInvoiceCurrency=in invoices currency paymentInInvoiceCurrency=in invoices currency
PaidBack=Paid back PaidBack=Paid back
DeletePayment=Delete payment DeletePayment=Delete payment
@ -78,7 +78,7 @@ ReceivedCustomersPaymentsToValid=Received customers payments to validate
PaymentsReportsForYear=Payments reports for %s PaymentsReportsForYear=Payments reports for %s
PaymentsReports=Payments reports PaymentsReports=Payments reports
PaymentsAlreadyDone=Payments already done PaymentsAlreadyDone=Payments already done
PaymentsBackAlreadyDone=Payments back already done PaymentsBackAlreadyDone=Refunds already done
PaymentRule=Payment rule PaymentRule=Payment rule
PaymentMode=Payment Type PaymentMode=Payment Type
PaymentTypeDC=Debit/Credit Card PaymentTypeDC=Debit/Credit Card

View File

@ -79,3 +79,5 @@ InvoiceIsAlreadyValidated=Invoice is already validated
NoLinesToBill=No lines to bill NoLinesToBill=No lines to bill
CustomReceipt=Custom Receipt CustomReceipt=Custom Receipt
ReceiptName=Receipt Name ReceiptName=Receipt Name
ProductSupplements=Product Supplements
SupplementCategory=Supplement category

View File

@ -251,9 +251,9 @@ ShowListTicketWithTrackId=Display ticket list from track ID
ShowTicketWithTrackId=Display ticket from track ID ShowTicketWithTrackId=Display ticket from track ID
TicketPublicDesc=You can create a support ticket or check from an existing ID. TicketPublicDesc=You can create a support ticket or check from an existing ID.
YourTicketSuccessfullySaved=Ticket has been successfully saved! YourTicketSuccessfullySaved=Ticket has been successfully saved!
MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s. MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s and Ref %s.
PleaseRememberThisId=Please keep the tracking number that we might ask you later. PleaseRememberThisId=Please keep the tracking number that we might ask you later.
TicketNewEmailSubject=Ticket creation confirmation TicketNewEmailSubject=Ticket creation confirmation - Ref %s
TicketNewEmailSubjectCustomer=New support ticket TicketNewEmailSubjectCustomer=New support ticket
TicketNewEmailBody=This is an automatic email to confirm you have registered a new ticket. TicketNewEmailBody=This is an automatic email to confirm you have registered a new ticket.
TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account. TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account.
@ -272,7 +272,7 @@ Subject=Subject
ViewTicket=View ticket ViewTicket=View ticket
ViewMyTicketList=View my ticket list ViewMyTicketList=View my ticket list
ErrorEmailMustExistToCreateTicket=Error: email address not found in our database ErrorEmailMustExistToCreateTicket=Error: email address not found in our database
TicketNewEmailSubjectAdmin=New ticket created TicketNewEmailSubjectAdmin=New ticket created - Ref %s
TicketNewEmailBodyAdmin=<p>Ticket has just been created with ID #%s, see information:</p> TicketNewEmailBodyAdmin=<p>Ticket has just been created with ID #%s, see information:</p>
SeeThisTicketIntomanagementInterface=See ticket in management interface SeeThisTicketIntomanagementInterface=See ticket in management interface
TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled

View File

@ -105,6 +105,10 @@ class Loan extends CommonObject
public $fk_project; public $fk_project;
const STATUS_UNPAID = 0;
const STATUS_PAID = 1;
/** /**
* Constructor * Constructor
* *
@ -427,45 +431,27 @@ class Loan extends CommonObject
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->loadLangs(array("customers", "bills"));
if ($mode == 0 || $mode == 1) // Load translation files required by the page
$langs->loadLangs(array("customers","bills"));
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{ {
if ($status == 0) return $langs->trans("Unpaid"); global $langs;
elseif ($status == 1) return $langs->trans("Paid"); //$langs->load("mymodule");
} $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid');
elseif ($mode == 2) $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid');
{ if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
}
elseif ($mode == 3)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 4)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
elseif ($mode == 5)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 6)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
} }
else return "Error, mode/status not found"; $statusType = 'status1';
if ($status == 0 && $alreadypaid > 0) $statusType = 'status3';
if ($status == 1) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }

View File

@ -49,7 +49,8 @@ if (!$sortorder) $sortorder = "DESC";
$search_ref = GETPOST('search_ref', 'int'); $search_ref = GETPOST('search_ref', 'int');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha');
$filtre = GETPOST("filtre");
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
// Purge search criteria // Purge search criteria
@ -77,10 +78,6 @@ $sql .= " WHERE l.entity = ".$conf->entity;
if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1);
if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref);
if ($search_label) $sql .= natural_search("l.label", $search_label); if ($search_label) $sql .= natural_search("l.label", $search_label);
if ($filtre) {
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
}
$sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -108,10 +105,10 @@ if ($resql)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref) $param.="&amp;search_ref=".urlencode($search_ref); if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_label) $param.="&amp;search_label=".urlencode($search_user); if ($search_label) $param.="&search_label=".urlencode($search_label);
if ($search_amount) $param.="&amp;search_amount=".urlencode($search_amount_ht); if ($search_amount) $param.="&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param.='&amp;optioncss='.urlencode($optioncss); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
$newcardbutton=''; $newcardbutton='';
if ($user->rights->loan->write) if ($user->rights->loan->write)
@ -130,6 +127,8 @@ if ($resql)
print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
$moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@ -157,7 +156,7 @@ if ($resql)
print_liste_field_titre(''); print_liste_field_titre('');
print "</tr>\n"; print "</tr>\n";
while ($i < min($num, $limit)) while ($i < ($limit ? min($num, $limit) : $num))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$loan_static->id = $obj->rowid; $loan_static->id = $obj->rowid;
@ -190,6 +189,14 @@ if ($resql)
$i++; $i++;
} }
// If no record found
if ($num == 0)
{
$colspan = 7;
//foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";

View File

@ -48,17 +48,17 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/loan/list.php?restore_lastsearch_values=1
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref loan // Ref loan
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->loadLangs(array("projects")); $langs->loadLangs(array("projects"));
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if ($user->rights->loan->write) if ($user->rights->loan->write)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; //$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
@ -83,6 +83,9 @@ if (!empty($conf->projet->enabled))
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$morehtmlright = '';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
if ($action == 'createecheancier') { if ($action == 'createecheancier') {
@ -140,8 +143,6 @@ if ($action == 'updateecheancier') {
$echeance = new LoanSchedule($db); $echeance = new LoanSchedule($db);
$echeance->fetchAll($object->id); $echeance->fetchAll($object->id);
$var = !$var;
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
@ -187,6 +188,8 @@ if (count($echeance->lines) > 0)
} else { } else {
print '<input type="hidden" name="action" value="createecheancier">'; print '<input type="hidden" name="action" value="createecheancier">';
} }
print '<div class="div-table-responsive-no-min">';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
$colspan = 6; $colspan = 6;
@ -197,12 +200,12 @@ print '</th>';
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th width="5%" class="center">'.$langs->trans("Term").'</th>'; print '<th class="center">'.$langs->trans("Term").'</th>';
print '<th width="5%" class="center">'.$langs->trans("Date").'</th>'; print '<th class="center">'.$langs->trans("Date").'</th>';
print '<th width="15%" class="center">'.$langs->trans("Insurance"); print '<th class="center">'.$langs->trans("Insurance");
print '<th width="15%" class="center">'.$langs->trans("InterestAmount").'</th>'; print '<th class="center">'.$langs->trans("InterestAmount").'</th>';
print '<th width="10%" class="center">'.$langs->trans("Amount").'</th>'; print '<th class="center">'.$langs->trans("Amount").'</th>';
print '<th width="40%" class="center">'.$langs->trans("CapitalRemain"); print '<th class="center">'.$langs->trans("CapitalRemain");
print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>'; print '</th>';
@ -276,8 +279,11 @@ elseif (count($echeance->lines) > 0)
} }
print '</table>'; print '</table>';
print '</div>';
print '</br>'; print '</br>';
print '</br>';
if (count($echeance->lines) == 0) $label = $langs->trans("Create"); if (count($echeance->lines) == 0) $label = $langs->trans("Create");
else $label = $langs->trans("Save"); else $label = $langs->trans("Save");
print '<div class="center"><input class="button" type="submit" value="'.$label.'"></div>'; print '<div class="center"><input class="button" type="submit" value="'.$label.'"></div>';

View File

@ -2552,7 +2552,7 @@ if (!function_exists("llxFooter"))
print '<div id="dialogforpopup" style="display: none;"></div>'."\n"; print '<div id="dialogforpopup" style="display: none;"></div>'."\n";
// Add code for the asynchronous anonymous first ping (for telemetry) // Add code for the asynchronous anonymous first ping (for telemetry)
// You can use &forceping=1 in parameters to force the ping. // You can use &forceping=1 in parameters to force the ping if the ping was already sent.
if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha'))
{ {
//print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->'; //print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->';
@ -2562,14 +2562,14 @@ if (!function_exists("llxFooter"))
|| GETPOST('forceping', 'alpha')) || GETPOST('forceping', 'alpha'))
{ {
if (strpos('alpha', DOL_VERSION) > 0) { if (strpos('alpha', DOL_VERSION) > 0) {
print "\n<!-- NO JS CODE TO ENABLE the anonymous One time Ping. It is an alpha version -->\n"; print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It is an alpha version -->\n";
} }
elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) // Cookie is set when we uncheck the checkbox in the installation wizard.
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
print "\n".'<!-- Includes JS for Ping of Dolibarr MAIN_FIRST_PING_OK_DATE = '.$conf->global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID = '.$conf->global->MAIN_FIRST_PING_OK_ID.' -->'."\n"; print "\n".'<!-- Includes JS for Ping of Dolibarr MAIN_FIRST_PING_OK_DATE = '.$conf->global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID = '.$conf->global->MAIN_FIRST_PING_OK_ID.' -->'."\n";
print "\n<!-- JS CODE TO ENABLE the anonymous Ontime Ping -->\n"; print "\n<!-- JS CODE TO ENABLE the anonymous Ping -->\n";
$url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING);
?> ?>
<script> <script>
@ -2618,7 +2618,7 @@ if (!function_exists("llxFooter"))
else else
{ {
$now = dol_now(); $now = dol_now();
print "\n<!-- NO JS CODE TO ENABLE the anonymous One time Ping. It was disabled -->\n"; print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It was disabled -->\n";
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt')); dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', 'disabled'); dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', 'disabled');

View File

@ -19,7 +19,7 @@
/** /**
* \file htdocs/product/ajax/products.php * \file htdocs/product/ajax/products.php
* \brief File to return Ajax response on product list request * \brief File to return Ajax response on product list request.
*/ */
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
@ -59,6 +59,7 @@ dol_syslog(join(',', $_GET));
if (!empty($action) && $action == 'fetch' && !empty($id)) if (!empty($action) && $action == 'fetch' && !empty($id))
{ {
// When action='fetch', id must be the product id.
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$outjson = array(); $outjson = array();

View File

@ -1597,7 +1597,7 @@ class Product extends CommonObject
* @param Societe $thirdparty_seller Seller * @param Societe $thirdparty_seller Seller
* @param Societe $thirdparty_buyer Buyer * @param Societe $thirdparty_buyer Buyer
* @param int $pqp Id of product per price if a selection was done of such a price * @param int $pqp Id of product per price if a selection was done of such a price
* @return array Array of price information * @return array Array of price information array('pu_ht'=> , 'pu_ttc'=> , 'tva_tx'=>'X.Y (code)', ...), 'tva_npr'=>0, ...)
* @see get_buyprice(), find_min_price_product_fournisseur() * @see get_buyprice(), find_min_price_product_fournisseur()
*/ */
public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)
@ -1615,8 +1615,7 @@ class Product extends CommonObject
$price_base_type = $this->price_base_type; $price_base_type = $this->price_base_type;
// If price per segment // If price per segment
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) {
{
$pu_ht = $this->multiprices[$thirdparty_buyer->price_level]; $pu_ht = $this->multiprices[$thirdparty_buyer->price_level];
$pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level]; $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level];
$price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; $price_min = $this->multiprices_min[$thirdparty_buyer->price_level];
@ -1629,8 +1628,7 @@ class Product extends CommonObject
} }
} }
// If price per customer // If price per customer
elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
{
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
@ -1651,8 +1649,7 @@ class Product extends CommonObject
} }
} }
// If price per quantity // If price per quantity
elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
{
if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity
{ {
// Search price into product_price_by_qty from $this->id // Search price into product_price_by_qty from $this->id
@ -1673,8 +1670,7 @@ class Product extends CommonObject
} }
} }
// If price per quantity and customer // If price per quantity and customer
elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
{
if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity
{ {
// Search price into product_price_by_qty from $this->id // Search price into product_price_by_qty from $this->id
@ -1877,6 +1873,9 @@ class Product extends CommonObject
if (empty($newnpr)) { if (empty($newnpr)) {
$newnpr = 0; $newnpr = 0;
} }
if (empty($newminprice)) {
$newminprice = 0;
}
// Check parameters // Check parameters
if ($newvat == '') { if ($newvat == '') {

View File

@ -109,7 +109,7 @@ $ErrorCode=$ErrorShortMsg=$ErrorLongMsg=$ErrorSeverityCode='';
$object = new stdClass(); // For triggers $object = new stdClass(); // For triggers
$error = 0;
/* /*
@ -205,11 +205,11 @@ if (! empty($conf->paypal->enabled))
if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
{ {
// Nothing to do // Nothing to do
dol_syslog("Call to GetExpressCheckoutDetails return ".$ack); dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment');
} }
else else
{ {
dol_syslog("Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING); dol_syslog("Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, '_payment');
} }
dol_syslog("We call DoExpressCheckoutPayment token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment'); dol_syslog("We call DoExpressCheckoutPayment token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment');
@ -219,7 +219,7 @@ if (! empty($conf->paypal->enabled))
$ack = strtoupper($resArray2["ACK"]); $ack = strtoupper($resArray2["ACK"]);
if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
{ {
dol_syslog("Call to GetExpressCheckoutDetails return ".$ack); dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment');
$object->source = $source; $object->source = $source;
$object->ref = $ref; $object->ref = $ref;
@ -238,7 +238,7 @@ if (! empty($conf->paypal->enabled))
} }
else else
{ {
dol_syslog("Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING); dol_syslog("Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0, '_payment');
//Display a user friendly Error on the page using any of the following error information returned by PayPal //Display a user friendly Error on the page using any of the following error information returned by PayPal
$ErrorCode = urldecode($resArray2["L_ERRORCODE0"]); $ErrorCode = urldecode($resArray2["L_ERRORCODE0"]);
@ -316,6 +316,8 @@ if ($ispaymentok)
$result1 = $object->fetch($tmptag['MEM']); $result1 = $object->fetch($tmptag['MEM']);
$result2 = $adht->fetch($object->typeid); $result2 = $adht->fetch($object->typeid);
dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment');
if ($result1 > 0 && $result2 > 0) if ($result1 > 0 && $result2 > 0)
{ {
$paymentTypeId = 0; $paymentTypeId = 0;
@ -331,6 +333,8 @@ if ($ispaymentok)
$currencyCodeType = $_SESSION['currencyCodeType']; $currencyCodeType = $_SESSION['currencyCodeType'];
dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId, LOG_DEBUG, 0, '_payment');
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) if (! empty($FinalPaymentAmt) && $paymentTypeId > 0)
{ {
@ -342,6 +346,7 @@ if ($ispaymentok)
$postactionmessages[] = $errmsg; $postactionmessages[] = $errmsg;
$postactionmessages = array_merge($postactionmessages, $object->errors); $postactionmessages = array_merge($postactionmessages, $object->errors);
$ispostactionok = -1; $ispostactionok = -1;
dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment');
} }
// Subscription informations // Subscription informations
@ -366,9 +371,10 @@ if ($ispaymentok)
if ($accountid < 0) if ($accountid < 0)
{ {
$error++; $error++;
$errmsg='Setup of bank accout to use for payment is not correctly done for payment method '.$paymentmethod; $errmsg='Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
$postactionmessages[] = $errmsg; $postactionmessages[] = $errmsg;
$ispostactionok = -1; $ispostactionok = -1;
dol_syslog("Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0, '_payment');
} }
$operation=$paymentType; // Payment mode code $operation=$paymentType; // Payment mode code
@ -471,8 +477,9 @@ if ($ispaymentok)
if (! $customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link if (! $customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link
{ {
dol_syslog("No stripe profile found, so we add it", LOG_DEBUG, 0, '_payment'); dol_syslog("No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0, '_payment');
try {
$ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id $ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id
$stripecu = $ch->customer; // value 'cus_....' $stripecu = $ch->customer; // value 'cus_....'
@ -487,6 +494,13 @@ if ($ispaymentok)
$ispostactionok = -1; $ispostactionok = -1;
} }
} }
catch(Exception $e) {
$error++;
$errmsg='Failed to save customer stripe id in database ; '.$e->getMessage();
$postactionmessages[] = $errmsg;
$ispostactionok = -1;
}
}
} }
} }
@ -836,10 +850,12 @@ if ($ispaymentok)
if ($result) if ($result)
{ {
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
//dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0);
} }
else else
{ {
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
//dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0);
} }
} }
} }

View File

@ -203,7 +203,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
// Send email to customer // Send email to customer
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject'); $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref);
$message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n"; $message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n";
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n"; $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n";
@ -245,7 +245,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
if ($sendto) if ($sendto)
{ {
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin'); $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref);
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n"; $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>'; $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>'; $message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
@ -314,7 +314,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
//setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs'); //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
// Make a redirect to avoid to have ticket submitted twice if we make back // Make a redirect to avoid to have ticket submitted twice if we make back
setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '<strong>'.$object->track_id.'</strong>'), null, 'warnings'); setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '<strong>'.$object->track_id.'</strong>', '<strong>' . $object->ref . '</strong>'), null, 'warnings');
setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
header("Location: index.php"); header("Location: index.php");
exit; exit;

View File

@ -75,6 +75,8 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_PHONE_BASIC_LAYOUT", GETPOST('TAKEPOS_PHONE_BASIC_LAYOUT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PHONE_BASIC_LAYOUT", GETPOST('TAKEPOS_PHONE_BASIC_LAYOUT', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS", GETPOST('TAKEPOS_SUPPLEMENTS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -222,6 +224,22 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
print '<td colspan="2">'; print '<td colspan="2">';
print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1); print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1);
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven value"><td>';
print $langs->trans("ProductSupplements");
print '<td colspan="2">';
print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
print '</td></tr>';
if ($conf->global->TAKEPOS_SUPPLEMENTS)
{
print '<tr class="oddeven"><td>';
print $langs->trans("SupplementCategory");
print '<td colspan="2">';
print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0);
print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY');
print "</td></tr>\n";
}
} }
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';

View File

@ -45,6 +45,7 @@ $id = GETPOST('id', 'int');
if ($action == 'getProducts') { if ($action == 'getProducts') {
$object = new Categorie($db); $object = new Categorie($db);
if ($category=="supplements") $category=$conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY;
$result = $object->fetch($category); $result = $object->fetch($category);
if ($result > 0) if ($result > 0)
{ {

View File

@ -43,6 +43,7 @@ $id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$idproduct = GETPOST('idproduct', 'int'); $idproduct = GETPOST('idproduct', 'int');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant
$placeid = 0; // $placeid is ID of invoice
if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone')
{ {
@ -83,10 +84,9 @@ function fail($message)
$placeid = 0; // $placeid is id of invoice
$number = GETPOST('number', 'alpha'); $number = GETPOST('number', 'alpha');
$idline = GETPOST('idline', 'int'); $idline = GETPOST('idline', 'int');
$selectedline = GETPOST('selectedline', 'int');
$desc = GETPOST('desc', 'alpha'); $desc = GETPOST('desc', 'alpha');
$pay = GETPOST('pay', 'alpha'); $pay = GETPOST('pay', 'alpha');
$amountofpayment = price2num(GETPOST('amount', 'alpha')); $amountofpayment = price2num(GETPOST('amount', 'alpha'));
@ -121,6 +121,12 @@ if ($ret > 0)
$placeid = $invoice->id; $placeid = $invoice->id;
} }
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid);
/* /*
* Actions * Actions
@ -233,7 +239,7 @@ if ($action == 'history')
if (($action == "addline" || $action == "freezone") && $placeid == 0) if (($action == "addline" || $action == "freezone") && $placeid == 0)
{ {
$invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; $invoice->socid = $conf->global->$constforcompanyid;
$invoice->date = dol_now(); $invoice->date = dol_now();
$invoice->module_source = 'takepos'; $invoice->module_source = 'takepos';
$invoice->pos_source = $_SESSION["takeposterminal"]; $invoice->pos_source = $_SESSION["takeposterminal"];
@ -263,27 +269,51 @@ if ($action == "addline")
$customer = new Societe($db); $customer = new Societe($db);
$customer->fetch($invoice->socid); $customer->fetch($invoice->socid);
$price = $prod->price; $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
$tva_tx = $prod->tva_tx;
$price_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
if (!empty($conf->global->PRODUIT_MULTIPRICES)) $price = $datapriceofproduct['pu_ht'];
$price_ttc = $datapriceofproduct['pu_ttc'];
//$price_min = $datapriceofproduct['price_min'];
$price_base_type = $datapriceofproduct['price_base_type'];
$tva_tx = $datapriceofproduct['tva_tx'];
$tva_npr = $datapriceofproduct['tva_npr'];
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
if (! empty($conf->global->TAKEPOS_SUPPLEMENTS))
{ {
$price = $prod->multiprices[$customer->price_level]; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$tva_tx = $prod->multiprices_tva_tx[$customer->price_level]; $cat = new Categorie($db);
$price_ttc = $prod->multiprices_ttc[$customer->price_level]; $categories = $cat->containing($idproduct, 'product');
$price_base_type = $prod->multiprices_base_type[$customer->price_level]; $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id')));
if ($found !== false) // If this product is a supplement
{
$sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
if ($row[0]==null) $parent_line=$selectedline;
else $parent_line=$row[0]; //If the parent line is already a supplement, add the supplement to the main product
}
} }
$idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "freezone") { if ($action == "freezone") {
$customer = new Societe($db); $customer = new Societe($db);
$customer->fetch($invoice->socid); $customer->fetch($invoice->socid);
$invoice->addline($desc, $number, 1, get_default_tva($mysoc, $customer), 0, 0, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
$tva_tx = get_default_tva($mysoc, $customer);
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
$invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
@ -392,7 +422,8 @@ if ($action == "order" and $placeid != 0)
$catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line)
{ {
if ($line->special_code == "4") { continue; if ($line->special_code == "4") {
continue;
} }
$c = new Categorie($db); $c = new Categorie($db);
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
@ -409,7 +440,8 @@ if ($action == "order" and $placeid != 0)
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line)
{ {
if ($line->special_code == "4") { continue; if ($line->special_code == "4") {
continue;
} }
$c = new Categorie($db); $c = new Categorie($db);
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
@ -618,6 +650,7 @@ if ($_SESSION["basiclayout"] != 1)
} }
print "</tr>\n"; print "</tr>\n";
if ($_SESSION["basiclayout"] == 1) if ($_SESSION["basiclayout"] == 1)
{ {
if ($mobilepage == "cats") if ($mobilepage == "cats")
@ -689,6 +722,37 @@ if ($placeid > 0)
$tmplines = array_reverse($invoice->lines); $tmplines = array_reverse($invoice->lines);
foreach ($tmplines as $line) foreach ($tmplines as $line)
{ {
if ($line->fk_parent_line!=false)
{
$htmlsupplements[$line->fk_parent_line].='<tr class="drag drop oddeven posinvoiceline';
if ($line->special_code == "4") $htmlsupplements[$line->fk_parent_line].=' order';
$htmlsupplements[$line->fk_parent_line].= '" id="'.$line->id.'">';
$htmlsupplements[$line->fk_parent_line].= '<td class="left">';
$htmlsupplements[$line->fk_parent_line].= img_picto('', 'rightarrow');
if ($line->product_label) $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
if ($line->product_label && $line->desc) $htmlsupplements[$line->fk_parent_line] .= '<br>';
if ($line->product_label != $line->desc)
{
$firstline = dolGetFirstLineOfText($line->desc);
if ($firstline != $line->desc)
{
$htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
}
else
{
$htmlsupplements[$line->fk_parent_line] .= $line->desc;
}
}
$htmlsupplements[$line->fk_parent_line] .= '</td>';
if ($_SESSION["basiclayout"] != 1)
{
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>';
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>';
}
$htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
continue;
}
$htmlforlines = ''; $htmlforlines = '';
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline'; $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
@ -720,12 +784,23 @@ if ($placeid > 0)
if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
if ($_SESSION["basiclayout"] != 1) if ($_SESSION["basiclayout"] != 1)
{ {
$moreinfo = '';
$moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht);
if ($line->vat_src_code) $moreinfo .= '<br>'.$langs->trans("VATCode").': '.$line->vat_src_code;
$moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_vat);
//$moreinfo .= '<br>'.$langs->transcountry("VATRate", $mysoc->country_code).': '.price($line->);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2);
$moreinfo .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc);
//$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht;
$htmlforlines .= '</td>'; $htmlforlines .= '</td>';
$htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>'; $htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
$htmlforlines .= '<td class="right">'.$line->qty.'</td>'; $htmlforlines .= '<td class="right">'.$line->qty.'</td>';
$htmlforlines .= '<td class="right">'.price($line->total_ttc).'</td>'; $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">'.price($line->total_ttc).'</td>';
} }
$htmlforlines .= '</tr>'."\n"; $htmlforlines .= '</tr>'."\n";
$htmlforlines .= $htmlsupplements[$line->id];
print $htmlforlines; print $htmlforlines;
} }
@ -741,12 +816,9 @@ else { // No invoice generated yet
print '</table>'; print '</table>';
if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]})
if ($invoice->socid != $conf->global->$constforcompanyid)
{ {
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid);
print '<!-- Show customer -->'; print '<!-- Show customer -->';
print '<p class="right">'; print '<p class="right">';
print $langs->trans("Customer").': '.$soc->name; print $langs->trans("Customer").': '.$soc->name;

View File

@ -34,11 +34,12 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$setterminal = GETPOST('setterminal', 'int'); $setterminal = GETPOST('setterminal', 'int');
@ -70,6 +71,13 @@ if ($conf->browser->layout == 'phone')
$MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
$MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
/*
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid);
*/
/* /*
* View * View
@ -233,10 +241,14 @@ function LoadProducts(position, issubcat) {
console.log("LoadProducts"); console.log("LoadProducts");
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>; var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
if (position=="supplements") currentcat="supplements";
else
{
$('#catimg'+position).animate({opacity: '0.5'}, 1); $('#catimg'+position).animate({opacity: '0.5'}, 1);
$('#catimg'+position).animate({opacity: '1'}, 100); $('#catimg'+position).animate({opacity: '1'}, 100);
if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
else currentcat=$('#catdiv'+position).data('rowid'); else currentcat=$('#catdiv'+position).data('rowid');
}
if (currentcat == undefined) return; if (currentcat == undefined) return;
pageproducts=0; pageproducts=0;
ishow=0; //product to show counter ishow=0; //product to show counter
@ -353,7 +365,7 @@ function ClickProduct(position) {
console.log("Click on product at position "+position+" for idproduct "+idproduct); console.log("Click on product at position "+position+" for idproduct "+idproduct);
if (idproduct=="") return; if (idproduct=="") return;
// Call page invoice.php to generate the section with product lines // Call page invoice.php to generate the section with product lines
$("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() { $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
@ -723,6 +735,10 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
{ {
$menus[$r++]=array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();'); $menus[$r++]=array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
} }
if ($conf->global->TAKEPOS_SUPPLEMENTS)
{
$menus[$r++]=array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
}
} }
if ($conf->global->TAKEPOSCONNECTOR) { if ($conf->global->TAKEPOSCONNECTOR) {

View File

@ -2,10 +2,12 @@
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com # @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
# @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro # @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
# @copyright GPL License 2017 - Laurent Destailleur - eldy@users.sourceforge.net # @copyright GPL License 2017 - Laurent Destailleur - eldy@users.sourceforge.net
# @copyright GPL License 2019 - Camille Lafitte - cam.lafit@azerttyu.net
# #
# Convert an ODT into a PDF using "jodconverter" or "pyodconverter" or "unoconv" tool. # Convert an ODT into a PDF using "native" or "jodconverter" or "pyodconverter" or "unoconv" tool.
# Dolibarr variable MAIN_ODT_AS_PDF must be defined # Dolibarr variable MAIN_ODT_AS_PDF must be defined
# to value "unoconv" to call unoconv CLI tool after ODT generation. # to value "native" to call soffice native exporter feature
# or value "unoconv" to call unoconv CLI tool after ODT generation.
# or value "pyodconverter" to call DocumentConverter.py after ODT generation. # or value "pyodconverter" to call DocumentConverter.py after ODT generation.
# or value "jodconverter" to call jodconverter wrapper after ODT generation # or value "jodconverter" to call jodconverter wrapper after ODT generation
# or value "/pathto/jodconverter-cli-file.jar" to call jodconverter java tool without wrapper after ODT generation. # or value "/pathto/jodconverter-cli-file.jar" to call jodconverter java tool without wrapper after ODT generation.
@ -14,7 +16,7 @@
if [ "x$1" == "x" ] if [ "x$1" == "x" ]
then then
echo "Usage: odt2pdf.sh fullfilename [unoconv|jodconverter|pyodconverter|pathtojodconverterjar]" echo "Usage: odt2pdf.sh fullfilename [native|unoconv|jodconverter|pyodconverter|pathtojodconverterjar]"
echo "Example: odt2pdf.sh myfile unoconv" echo "Example: odt2pdf.sh myfile unoconv"
echo "Example: odt2pdf.sh myfile ~/jodconverter/jodconverter-cli-2.2.2.jar" echo "Example: odt2pdf.sh myfile ~/jodconverter/jodconverter-cli-2.2.2.jar"
exit exit
@ -34,6 +36,12 @@ home_java="/tmp"
if [ -f "$1.odt" ] if [ -f "$1.odt" ]
then then
if [ "x$2" == "xnative" ]
then
$soffice --headless -env:UserInstallation=file:///$home_java/ --convert-to pdf:writer_pdf_Export --outdir $(dirname $1) "$1.odt"
exit 0
fi
if [ "x$2" == "xunoconv" ] if [ "x$2" == "xunoconv" ]
then then
# See issue https://github.com/dagwieers/unoconv/issues/87 # See issue https://github.com/dagwieers/unoconv/issues/87