Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
f5da126cff
commit
ddcc14dc16
@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("errors","admin","companies","resource","holiday","accountancy","hrm"));
|
||||
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "accountancy", "hrm"));
|
||||
|
||||
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
|
||||
$confirm=GETPOST('confirm', 'alpha');
|
||||
$id=32;
|
||||
$rowid=GETPOST('rowid', 'alpha');
|
||||
$code=GETPOST('code', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$id = 32;
|
||||
$rowid = GETPOST('rowid', 'alpha');
|
||||
$code = GETPOST('code', 'alpha');
|
||||
|
||||
// Security access
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
@ -50,15 +50,15 @@ $acts[1] = "disable";
|
||||
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
|
||||
|
||||
$listoffset=GETPOST('listoffset', 'alpha');
|
||||
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
|
||||
$listoffset = GETPOST('listoffset', 'alpha');
|
||||
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
|
||||
$active = 1;
|
||||
|
||||
$sortfield = GETPOST("sortfield", 'aZ09comma');
|
||||
$sortorder = GETPOST("sortorder", 'aZ09comma');
|
||||
$page = GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $listlimit * $page ;
|
||||
$offset = $listlimit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -71,52 +71,52 @@ $hookmanager->initHooks(array('admin'));
|
||||
// Put here declaration of dictionaries properties
|
||||
|
||||
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
|
||||
$taborder=array(32);
|
||||
$taborder = array(32);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname=array();
|
||||
$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
|
||||
$tabname = array();
|
||||
$tabname[32] = MAIN_DB_PREFIX."c_accounting_category";
|
||||
|
||||
// Dictionary labels
|
||||
$tablib=array();
|
||||
$tablib[32]= "DictionaryAccountancyCategory";
|
||||
$tablib = array();
|
||||
$tablib[32] = "DictionaryAccountancyCategory";
|
||||
|
||||
// Requests to extract data
|
||||
$tabsql=array();
|
||||
$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
|
||||
$tabsql = array();
|
||||
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort=array();
|
||||
$tabsqlsort[32]="position ASC";
|
||||
$tabsqlsort = array();
|
||||
$tabsqlsort[32] = "position ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[32]= "code,label,range_account,category_type,formula,position,country";
|
||||
$tabfield = array();
|
||||
$tabfield[32] = "code,label,range_account,category_type,formula,position,country";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[32]= "code,label,range_account,category_type,formula,position,country_id";
|
||||
$tabfieldvalue = array();
|
||||
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id";
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[32]= "code,label,range_account,category_type,formula,position,fk_country";
|
||||
$tabfieldinsert = array();
|
||||
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country";
|
||||
|
||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||
// Example: "" if id field is "rowid" and has autoincrement on
|
||||
// "nameoffield" if id field is not "rowid" or has not autoincrement on
|
||||
$tabrowid=array();
|
||||
$tabrowid[32]= "";
|
||||
$tabrowid = array();
|
||||
$tabrowid[32] = "";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond=array();
|
||||
$tabcond[32]= ! empty($conf->accounting->enabled);
|
||||
$tabcond = array();
|
||||
$tabcond[32] = !empty($conf->accounting->enabled);
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp=array();
|
||||
$tabhelp = array();
|
||||
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes"));
|
||||
|
||||
// List of check for fields (NOT USED YET)
|
||||
$tabfieldcheck=array();
|
||||
$tabfieldcheck = array();
|
||||
$tabfieldcheck[32] = array();
|
||||
|
||||
// Complete all arrays with entries found into modules
|
||||
@ -125,7 +125,7 @@ complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqls
|
||||
|
||||
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
|
||||
$elementList = array();
|
||||
$sourceList=array();
|
||||
$sourceList = array();
|
||||
|
||||
|
||||
|
||||
@ -141,24 +141,24 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
||||
|
||||
// Check that all fields are filled
|
||||
$ok=1;
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if ($value == 'formula' && empty($_POST['formula'])) continue;
|
||||
if ($value == 'range_account' && empty($_POST['range_account'])) continue;
|
||||
if ($value == 'country' || $value == 'country_id') continue;
|
||||
if (! isset($_POST[$value]) || $_POST[$value]=='')
|
||||
if (!isset($_POST[$value]) || $_POST[$value] == '')
|
||||
{
|
||||
$ok=0;
|
||||
$fieldnamekey=$listfield[$f];
|
||||
$ok = 0;
|
||||
$fieldnamekey = $listfield[$f];
|
||||
// We take translate key of field
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
|
||||
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
|
||||
@ -170,23 +170,23 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
}
|
||||
if (isset($_POST["code"]))
|
||||
{
|
||||
if ($_POST["code"]=='0')
|
||||
if ($_POST["code"] == '0')
|
||||
{
|
||||
$ok=0;
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
}
|
||||
if (! is_numeric(GETPOST('position', 'alpha')))
|
||||
if (!is_numeric(GETPOST('position', 'alpha')))
|
||||
{
|
||||
$langs->loadLangs(array("errors"));
|
||||
$ok=0;
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
||||
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd', 'alpha'))
|
||||
@ -194,13 +194,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
// Recupere id libre pour insertion
|
||||
$newid=0;
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid=($obj->newid + 1);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
@ -209,32 +209,32 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Add new entry
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $tabrowid[$id].",";
|
||||
$sql.= $tabfieldinsert[$id];
|
||||
$sql.=",active)";
|
||||
$sql.= " VALUES(";
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].",";
|
||||
$sql .= $tabfieldinsert[$id];
|
||||
$sql .= ",active)";
|
||||
$sql .= " VALUES(";
|
||||
|
||||
// List of values
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $newid.",";
|
||||
$i=0;
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.",";
|
||||
$i = 0;
|
||||
foreach ($listfieldinsert as $f => $value)
|
||||
{
|
||||
if ($value == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'formula') $sql.="null"; // For vat, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) $sql .= ",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.=",1)";
|
||||
$sql .= ",1)";
|
||||
|
||||
dol_syslog("actionadd", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) // Add is ok
|
||||
{
|
||||
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
|
||||
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
|
||||
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -250,16 +250,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
|
||||
{
|
||||
$sql.= $tabrowid[$id]."=";
|
||||
$sql.= "'".$db->escape($rowid)."', ";
|
||||
$sql .= $tabrowid[$id]."=";
|
||||
$sql .= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
@ -270,18 +270,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
elseif ($field == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
$sql.= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'range_account') $sql.="null"; // For range_account, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) $sql .= ",";
|
||||
$sql .= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
if (!$resql)
|
||||
{
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
@ -296,14 +296,14 @@ if (GETPOST('actioncancel', 'alpha'))
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
if (!$result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
@ -319,8 +319,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
// activate
|
||||
if ($action == $acts[0])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||
@ -339,8 +339,8 @@ if ($action == $acts[0])
|
||||
// disable
|
||||
if ($action == $acts[1])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||
@ -359,8 +359,8 @@ if ($action == $acts[1])
|
||||
// favorite
|
||||
if ($action == 'activate_favorite')
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||
@ -379,8 +379,8 @@ if ($action == 'activate_favorite')
|
||||
// disable favorite
|
||||
if ($action == 'disable_favorite')
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||
@ -402,13 +402,13 @@ if ($action == 'disable_favorite')
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formadmin=new FormAdmin($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
|
||||
llxHeader('', $langs->trans('DictionaryAccountancyCategory'));
|
||||
|
||||
$titre=$langs->trans($tablib[$id]);
|
||||
$linkback='';
|
||||
$titlepicto='title_setup';
|
||||
$titre = $langs->trans($tablib[$id]);
|
||||
$linkback = '';
|
||||
$titlepicto = 'title_setup';
|
||||
|
||||
print load_fiche_titre($titre, $linkback, $titlepicto);
|
||||
|
||||
@ -417,7 +417,7 @@ print '<span class="opacitymedium">'.$langs->trans("AccountingAccountGroupsDesc"
|
||||
// Confirmation de la suppression de la ligne
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id>0?'&search_country_id='.$search_country_id:''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
//var_dump($elementList);
|
||||
|
||||
@ -427,22 +427,22 @@ if ($action == 'delete')
|
||||
if ($id)
|
||||
{
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql=$tabsql[$id];
|
||||
$sql = $tabsql[$id];
|
||||
|
||||
if ($search_country_id > 0)
|
||||
{
|
||||
if (preg_match('/ WHERE /', $sql)) $sql.= " AND ";
|
||||
else $sql.=" WHERE ";
|
||||
$sql.= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
|
||||
if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
|
||||
else $sql .= " WHERE ";
|
||||
$sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
|
||||
}
|
||||
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield='country_code';
|
||||
$sql.=$db->order($sortfield, $sortorder);
|
||||
$sql.=$db->plimit($listlimit+1, $offset);
|
||||
if ($sortfield == 'country') $sortfield = 'country_code';
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($listlimit + 1, $offset);
|
||||
//print $sql;
|
||||
|
||||
$fieldlist=explode(',', $tabfield[$id]);
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -454,9 +454,9 @@ if ($id)
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused=0;
|
||||
$alabelisused = 0;
|
||||
|
||||
$fieldlist=explode(',', $tabfield[$id]);
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
@ -464,55 +464,55 @@ if ($id)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
$class="left";
|
||||
if ($fieldlist[$field]=='type') {
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
$class = "left";
|
||||
if ($fieldlist[$field] == 'type') {
|
||||
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") {
|
||||
$valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
|
||||
$valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
|
||||
} else {
|
||||
$valuetoshow=$langs->trans("Type");
|
||||
$valuetoshow = $langs->trans("Type");
|
||||
}
|
||||
}
|
||||
if ($fieldlist[$field]=='code') {
|
||||
$valuetoshow=$langs->trans("Code");
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle_facture') {
|
||||
$valuetoshow=$langs->trans("LabelOnDocuments");
|
||||
if ($fieldlist[$field] == 'libelle_facture') {
|
||||
$valuetoshow = $langs->trans("LabelOnDocuments");
|
||||
}
|
||||
if ($fieldlist[$field]=='country') {
|
||||
$valuetoshow=$langs->trans("Country");
|
||||
if ($fieldlist[$field] == 'country') {
|
||||
$valuetoshow = $langs->trans("Country");
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code') {
|
||||
$valuetoshow=$langs->trans("AccountancyCode");
|
||||
if ($fieldlist[$field] == 'accountancy_code') {
|
||||
$valuetoshow = $langs->trans("AccountancyCode");
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code_sell') {
|
||||
$valuetoshow=$langs->trans("AccountancyCodeSell");
|
||||
if ($fieldlist[$field] == 'accountancy_code_sell') {
|
||||
$valuetoshow = $langs->trans("AccountancyCodeSell");
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code_buy') {
|
||||
$valuetoshow=$langs->trans("AccountancyCodeBuy");
|
||||
if ($fieldlist[$field] == 'accountancy_code_buy') {
|
||||
$valuetoshow = $langs->trans("AccountancyCodeBuy");
|
||||
}
|
||||
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') {
|
||||
$valuetoshow=$langs->trans("Pcg_version");
|
||||
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
|
||||
$valuetoshow = $langs->trans("Pcg_version");
|
||||
}
|
||||
if ($fieldlist[$field]=='range_account') {
|
||||
$valuetoshow=$langs->trans("Comment");
|
||||
if ($fieldlist[$field] == 'range_account') {
|
||||
$valuetoshow = $langs->trans("Comment");
|
||||
}
|
||||
if ($fieldlist[$field]=='category_type') {
|
||||
$valuetoshow=$langs->trans("Calculated");
|
||||
if ($fieldlist[$field] == 'category_type') {
|
||||
$valuetoshow = $langs->trans("Calculated");
|
||||
}
|
||||
|
||||
if ($valuetoshow != '') {
|
||||
print '<td class="'.$class.'">';
|
||||
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
|
||||
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
|
||||
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
else print $valuetoshow;
|
||||
print '</td>';
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
@ -533,14 +533,14 @@ if ($id)
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val) != '')
|
||||
$obj->$val=GETPOST($val);
|
||||
$obj->$val = GETPOST($val);
|
||||
}
|
||||
}
|
||||
|
||||
$tmpaction = 'create';
|
||||
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
@ -552,42 +552,42 @@ if ($id)
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
|
||||
$colspan=count($fieldlist)+3;
|
||||
$colspan = count($fieldlist) + 3;
|
||||
if ($id == 32) $colspan++;
|
||||
|
||||
print '<tr><td colspan="'.$colspan.'"> </td></tr>'; // Keep to have a line with enough height
|
||||
print '<tr><td colspan="'.$colspan.'"> </td></tr>'; // Keep to have a line with enough height
|
||||
}
|
||||
|
||||
// List of available record in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
|
||||
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
|
||||
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
|
||||
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre liste_titre_add liste_titre_filter">';
|
||||
$filterfound=0;
|
||||
$filterfound = 0;
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1; // By defaut
|
||||
$showfield = 1; // By defaut
|
||||
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
|
||||
|
||||
if ($showfield)
|
||||
{
|
||||
@ -610,7 +610,7 @@ if ($id)
|
||||
print '<td class="liste_titre center">';
|
||||
if ($filterfound)
|
||||
{
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
}
|
||||
print '</td>';
|
||||
@ -622,80 +622,80 @@ if ($id)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
$class="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
$showfield = 1; // By defaut
|
||||
$class = "left";
|
||||
$sortable = 1;
|
||||
$valuetoshow = '';
|
||||
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field]=='source') {
|
||||
$valuetoshow=$langs->trans("Contact");
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field] == 'source') {
|
||||
$valuetoshow = $langs->trans("Contact");
|
||||
}
|
||||
if ($fieldlist[$field]=='price') {
|
||||
$valuetoshow=$langs->trans("PriceUHT");
|
||||
if ($fieldlist[$field] == 'price') {
|
||||
$valuetoshow = $langs->trans("PriceUHT");
|
||||
}
|
||||
if ($fieldlist[$field]=='taux') {
|
||||
if ($fieldlist[$field] == 'taux') {
|
||||
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") {
|
||||
$valuetoshow=$langs->trans("Rate");
|
||||
$valuetoshow = $langs->trans("Rate");
|
||||
} else {
|
||||
$valuetoshow=$langs->trans("Amount");
|
||||
$valuetoshow = $langs->trans("Amount");
|
||||
}
|
||||
$class='center';
|
||||
$class = 'center';
|
||||
}
|
||||
if ($fieldlist[$field]=='type') {
|
||||
$valuetoshow=$langs->trans("Type");
|
||||
if ($fieldlist[$field] == 'type') {
|
||||
$valuetoshow = $langs->trans("Type");
|
||||
}
|
||||
if ($fieldlist[$field]=='code') {
|
||||
$valuetoshow=$langs->trans("Code");
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='country') {
|
||||
$valuetoshow=$langs->trans("Country");
|
||||
if ($fieldlist[$field] == 'country') {
|
||||
$valuetoshow = $langs->trans("Country");
|
||||
}
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
|
||||
$showfield=0;
|
||||
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
|
||||
$showfield = 0;
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code') {
|
||||
$valuetoshow=$langs->trans("AccountancyCode");
|
||||
if ($fieldlist[$field] == 'accountancy_code') {
|
||||
$valuetoshow = $langs->trans("AccountancyCode");
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code_sell') {
|
||||
$valuetoshow=$langs->trans("AccountancyCodeSell");
|
||||
$sortable=0;
|
||||
if ($fieldlist[$field] == 'accountancy_code_sell') {
|
||||
$valuetoshow = $langs->trans("AccountancyCodeSell");
|
||||
$sortable = 0;
|
||||
}
|
||||
if ($fieldlist[$field]=='accountancy_code_buy') {
|
||||
$valuetoshow=$langs->trans("AccountancyCodeBuy");
|
||||
$sortable=0;
|
||||
if ($fieldlist[$field] == 'accountancy_code_buy') {
|
||||
$valuetoshow = $langs->trans("AccountancyCodeBuy");
|
||||
$sortable = 0;
|
||||
}
|
||||
if ($fieldlist[$field]=='fk_pcg_version') {
|
||||
$valuetoshow=$langs->trans("Pcg_version");
|
||||
if ($fieldlist[$field] == 'fk_pcg_version') {
|
||||
$valuetoshow = $langs->trans("Pcg_version");
|
||||
}
|
||||
if ($fieldlist[$field]=='account_parent') {
|
||||
$valuetoshow=$langs->trans("Accountsparent");
|
||||
if ($fieldlist[$field] == 'account_parent') {
|
||||
$valuetoshow = $langs->trans("Accountsparent");
|
||||
}
|
||||
if ($fieldlist[$field]=='pcg_type') {
|
||||
$valuetoshow=$langs->trans("Pcg_type");
|
||||
if ($fieldlist[$field] == 'pcg_type') {
|
||||
$valuetoshow = $langs->trans("Pcg_type");
|
||||
}
|
||||
if ($fieldlist[$field]=='pcg_subtype') {
|
||||
$valuetoshow=$langs->trans("Pcg_subtype");
|
||||
if ($fieldlist[$field] == 'pcg_subtype') {
|
||||
$valuetoshow = $langs->trans("Pcg_subtype");
|
||||
}
|
||||
if ($fieldlist[$field]=='type_template') {
|
||||
$valuetoshow=$langs->trans("TypeOfTemplate");
|
||||
if ($fieldlist[$field] == 'type_template') {
|
||||
$valuetoshow = $langs->trans("TypeOfTemplate");
|
||||
}
|
||||
if ($fieldlist[$field]=='range_account') {
|
||||
$valuetoshow=$langs->trans("Comment");
|
||||
if ($fieldlist[$field] == 'range_account') {
|
||||
$valuetoshow = $langs->trans("Comment");
|
||||
}
|
||||
if ($fieldlist[$field]=='category_type') {
|
||||
$valuetoshow=$langs->trans("Calculated");
|
||||
if ($fieldlist[$field] == 'category_type') {
|
||||
$valuetoshow = $langs->trans("Calculated");
|
||||
}
|
||||
// Affiche nom du champ
|
||||
if ($showfield) {
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
|
||||
}
|
||||
}
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
@ -709,12 +709,12 @@ if ($id)
|
||||
$obj = $db->fetch_object($resql);
|
||||
//print_r($obj);
|
||||
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
|
||||
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
|
||||
{
|
||||
$tmpaction='edit';
|
||||
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$tmpaction = 'edit';
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
@ -725,7 +725,7 @@ if ($id)
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
|
||||
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
|
||||
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
@ -733,71 +733,71 @@ if ($id)
|
||||
else
|
||||
{
|
||||
$tmpaction = 'view';
|
||||
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1;
|
||||
$class="left";
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
$showfield = 1;
|
||||
$class = "left";
|
||||
$valuetoshow = $obj->{$fieldlist[$field]};
|
||||
if ($value == 'category_type')
|
||||
{
|
||||
$valuetoshow = yn($valuetoshow);
|
||||
}
|
||||
elseif ($valuetoshow=='all') {
|
||||
$valuetoshow=$langs->trans('All');
|
||||
elseif ($valuetoshow == 'all') {
|
||||
$valuetoshow = $langs->trans('All');
|
||||
}
|
||||
elseif ($fieldlist[$field]=='country') {
|
||||
elseif ($fieldlist[$field] == 'country') {
|
||||
if (empty($obj->country_code))
|
||||
{
|
||||
$valuetoshow='-';
|
||||
$valuetoshow = '-';
|
||||
}
|
||||
else
|
||||
{
|
||||
$key=$langs->trans("Country".strtoupper($obj->country_code));
|
||||
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
|
||||
$key = $langs->trans("Country".strtoupper($obj->country_code));
|
||||
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
|
||||
}
|
||||
}
|
||||
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') {
|
||||
$key=$langs->trans("Country".strtoupper($obj->code));
|
||||
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
|
||||
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
|
||||
$key = $langs->trans("Country".strtoupper($obj->code));
|
||||
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
|
||||
}
|
||||
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
|
||||
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
|
||||
$langs->loadLangs(array("propal"));
|
||||
$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
|
||||
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
|
||||
$key = $langs->trans("AvailabilityType".strtoupper($obj->code));
|
||||
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
|
||||
}
|
||||
elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') {
|
||||
$key=$langs->trans("Action".strtoupper($obj->code));
|
||||
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
|
||||
elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
|
||||
$key = $langs->trans("Action".strtoupper($obj->code));
|
||||
$valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
|
||||
}
|
||||
elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
|
||||
$showfield=0;
|
||||
elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
|
||||
$showfield = 0;
|
||||
}
|
||||
|
||||
$class='tddict';
|
||||
$class = 'tddict';
|
||||
// Show value for field
|
||||
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
|
||||
// Can an entry be erased or disabled ?
|
||||
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
|
||||
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
|
||||
if (isset($obj->code))
|
||||
{
|
||||
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; }
|
||||
}
|
||||
|
||||
$canbemodified=$iserasable;
|
||||
$canbemodified = $iserasable;
|
||||
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
|
||||
if ($param) $url .= '&'.$param;
|
||||
$url.='&';
|
||||
$url .= '&';
|
||||
|
||||
// Active
|
||||
print '<td class="center" class="nowrap">';
|
||||
@ -865,38 +865,38 @@ $db->close();
|
||||
*/
|
||||
function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
{
|
||||
global $conf,$langs,$db;
|
||||
global $conf, $langs, $db;
|
||||
global $form, $mysoc;
|
||||
global $region_id;
|
||||
global $elementList,$sourceList,$localtax_typeList;
|
||||
global $elementList, $sourceList, $localtax_typeList;
|
||||
global $bc;
|
||||
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'country')
|
||||
{
|
||||
print '<td>';
|
||||
$fieldname='country';
|
||||
$fieldname = 'country';
|
||||
if ($context == 'add')
|
||||
{
|
||||
$fieldname='country_id';
|
||||
$fieldname = 'country_id';
|
||||
print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:$mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'country_id')
|
||||
{
|
||||
if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
|
||||
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
|
||||
{
|
||||
$country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
|
||||
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
|
||||
print '</td>';
|
||||
@ -904,21 +904,21 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'category_type') {
|
||||
print '<td>';
|
||||
print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
|
||||
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
|
||||
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
|
||||
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
$size=''; $class='';
|
||||
if ($fieldlist[$field]=='code') $class='maxwidth100';
|
||||
if ($fieldlist[$field]=='position') $class='maxwidth50';
|
||||
if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
|
||||
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='category_type') $size='size="2" ';
|
||||
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
$size = ''; $class = '';
|
||||
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
|
||||
if ($fieldlist[$field] == 'position') $class = 'maxwidth50';
|
||||
if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent';
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
|
||||
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan"));
|
||||
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan"));
|
||||
|
||||
// Security check
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
@ -97,12 +97,12 @@ if (GETPOST('change_chart', 'alpha'))
|
||||
{
|
||||
$chartofaccounts = GETPOST('chartofaccounts', 'int');
|
||||
|
||||
if (! empty($chartofaccounts)) {
|
||||
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
if (!empty($chartofaccounts)) {
|
||||
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,8 +153,8 @@ print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_a
|
||||
print '<span class="opacitymedium">'.$langs->trans("DefaultBindingDesc").'</span><br>';
|
||||
print '<br>';
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
|
||||
@ -166,14 +166,14 @@ foreach ($list_account_main as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
$keydesc=$key.'_Desc';
|
||||
$keydesc = $key.'_Desc';
|
||||
|
||||
$htmltext = $langs->trans($keydesc);
|
||||
print '<td class="fieldrequired" width="50%">';
|
||||
print $form->textwithpicto($label, $htmltext);
|
||||
print '</td>';
|
||||
// Value
|
||||
print '<td>'; // Do not force class=right, or it align also the content of the select box
|
||||
print '<td>'; // Do not force class=right, or it align also the content of the select box
|
||||
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -211,7 +211,7 @@ foreach ($list_account as $key) {
|
||||
print "</table>\n";
|
||||
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
|
||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin","compta","accountancy"));
|
||||
$langs->loadLangs(array("admin", "compta", "accountancy"));
|
||||
|
||||
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
|
||||
$confirm=GETPOST('confirm', 'alpha');
|
||||
$id=35;
|
||||
$rowid=GETPOST('rowid', 'alpha');
|
||||
$code=GETPOST('code', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$id = 35;
|
||||
$rowid = GETPOST('rowid', 'alpha');
|
||||
$code = GETPOST('code', 'alpha');
|
||||
|
||||
// Security access
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
@ -51,19 +51,19 @@ $acts[1] = "disable";
|
||||
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
|
||||
|
||||
$listoffset=GETPOST('listoffset', 'alpha');
|
||||
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
|
||||
$listoffset = GETPOST('listoffset', 'alpha');
|
||||
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
|
||||
$active = 1;
|
||||
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $listlimit * $page ;
|
||||
$offset = $listlimit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (empty($sortfield)) $sortfield='code';
|
||||
if (empty($sortorder)) $sortorder='ASC';
|
||||
if (empty($sortfield)) $sortfield = 'code';
|
||||
if (empty($sortorder)) $sortorder = 'ASC';
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -74,52 +74,52 @@ $hookmanager->initHooks(array('admin'));
|
||||
// Put here declaration of dictionaries properties
|
||||
|
||||
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
|
||||
$taborder=array(35);
|
||||
$taborder = array(35);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname=array();
|
||||
$tabname[35]= MAIN_DB_PREFIX."accounting_journal";
|
||||
$tabname = array();
|
||||
$tabname[35] = MAIN_DB_PREFIX."accounting_journal";
|
||||
|
||||
// Dictionary labels
|
||||
$tablib=array();
|
||||
$tablib[35]= "DictionaryAccountancyJournal";
|
||||
$tablib = array();
|
||||
$tablib[35] = "DictionaryAccountancyJournal";
|
||||
|
||||
// Requests to extract data
|
||||
$tabsql=array();
|
||||
$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
|
||||
$tabsql = array();
|
||||
$tabsql[35] = "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort=array();
|
||||
$tabsqlsort[35]="code ASC";
|
||||
$tabsqlsort = array();
|
||||
$tabsqlsort[35] = "code ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[35]= "code,label,nature";
|
||||
$tabfield = array();
|
||||
$tabfield[35] = "code,label,nature";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[35]= "code,label,nature";
|
||||
$tabfieldvalue = array();
|
||||
$tabfieldvalue[35] = "code,label,nature";
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[35]= "code,label,nature";
|
||||
$tabfieldinsert = array();
|
||||
$tabfieldinsert[35] = "code,label,nature";
|
||||
|
||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||
// Example: "" if id field is "rowid" and has autoincrement on
|
||||
// "nameoffield" if id field is not "rowid" or has not autoincrement on
|
||||
$tabrowid=array();
|
||||
$tabrowid[35]= "";
|
||||
$tabrowid = array();
|
||||
$tabrowid[35] = "";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond=array();
|
||||
$tabcond[35]= ! empty($conf->accounting->enabled);
|
||||
$tabcond = array();
|
||||
$tabcond[35] = !empty($conf->accounting->enabled);
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp=array();
|
||||
$tabhelp = array();
|
||||
$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
|
||||
// List of check for fields (NOT USED YET)
|
||||
$tabfieldcheck=array();
|
||||
$tabfieldcheck = array();
|
||||
$tabfieldcheck[35] = array();
|
||||
|
||||
// Complete all arrays with entries found into modules
|
||||
@ -151,25 +151,25 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
||||
|
||||
// Check that all fields are filled
|
||||
$ok=1;
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal';
|
||||
}
|
||||
// Other checks
|
||||
if (isset($_POST["code"]))
|
||||
{
|
||||
if ($_POST["code"]=='0')
|
||||
if ($_POST["code"] == '0')
|
||||
{
|
||||
$ok=0;
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
|
||||
@ -178,16 +178,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
}
|
||||
if (! GETPOST('label', 'alpha'))
|
||||
if (!GETPOST('label', 'alpha'))
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$ok=0;
|
||||
$ok = 0;
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
||||
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd', 'alpha'))
|
||||
@ -195,13 +195,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
// Recupere id libre pour insertion
|
||||
$newid=0;
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid=($obj->newid + 1);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
@ -210,34 +210,34 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Add new entry
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
|
||||
$sql.= $tabrowid[$id].",";
|
||||
$sql.= $tabfieldinsert[$id];
|
||||
$sql.=",active,entity)";
|
||||
$sql.= " VALUES(";
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
$sql .= $tabrowid[$id].",";
|
||||
$sql .= $tabfieldinsert[$id];
|
||||
$sql .= ",active,entity)";
|
||||
$sql .= " VALUES(";
|
||||
|
||||
// List of values
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
|
||||
$sql.= $newid.",";
|
||||
$i=0;
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
$sql .= $newid.",";
|
||||
$i = 0;
|
||||
foreach ($listfieldinsert as $f => $value)
|
||||
{
|
||||
if ($value == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) $sql .= ",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.=",1,".$conf->entity.")";
|
||||
$sql .= ",1,".$conf->entity.")";
|
||||
|
||||
dol_syslog("actionadd", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) // Add is ok
|
||||
{
|
||||
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
|
||||
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
|
||||
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -253,16 +253,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
|
||||
{
|
||||
$sql.= $tabrowid[$id]."=";
|
||||
$sql.= "'".$db->escape($rowid)."', ";
|
||||
$sql .= $tabrowid[$id]."=";
|
||||
$sql .= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
@ -273,19 +273,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
elseif ($field == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
$sql.= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) $sql .= ",";
|
||||
$sql .= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
$sql.=" AND entity = ".$conf->entity;
|
||||
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
if (!$resql)
|
||||
{
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
@ -300,15 +300,15 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql.=" AND entity = ".$conf->entity;
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
if (!$result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
@ -324,8 +324,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
// activate
|
||||
if ($action == $acts[0])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
@ -333,7 +333,7 @@ if ($action == $acts[0])
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
|
||||
}
|
||||
$sql.=" AND entity = ".$conf->entity;
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
@ -345,8 +345,8 @@ if ($action == $acts[0])
|
||||
// disable
|
||||
if ($action == $acts[1])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
|
||||
else { $rowidcol = "rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
@ -354,7 +354,7 @@ if ($action == $acts[1])
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
|
||||
}
|
||||
$sql.=" AND entity = ".$conf->entity;
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
@ -369,16 +369,16 @@ if ($action == $acts[1])
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formadmin=new FormAdmin($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$titre=$langs->trans("DictionarySetup");
|
||||
$linkback='';
|
||||
$titre = $langs->trans("DictionarySetup");
|
||||
$linkback = '';
|
||||
if ($id)
|
||||
{
|
||||
$titre.=' - '.$langs->trans($tablib[$id]);
|
||||
$titlepicto='title_accountancy';
|
||||
$titre .= ' - '.$langs->trans($tablib[$id]);
|
||||
$titlepicto = 'title_accountancy';
|
||||
}
|
||||
|
||||
print load_fiche_titre($titre, $linkback, $titlepicto);
|
||||
@ -387,7 +387,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
|
||||
// Confirmation de la suppression de la ligne
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
//var_dump($elementList);
|
||||
|
||||
@ -397,15 +397,15 @@ if ($action == 'delete')
|
||||
if ($id)
|
||||
{
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql=$tabsql[$id];
|
||||
$sql.= " WHERE a.entity = ".$conf->entity;
|
||||
$sql = $tabsql[$id];
|
||||
$sql .= " WHERE a.entity = ".$conf->entity;
|
||||
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield='country_code';
|
||||
$sql.=$db->order($sortfield, $sortorder);
|
||||
$sql.=$db->plimit($listlimit+1, $offset);
|
||||
if ($sortfield == 'country') $sortfield = 'country_code';
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($listlimit + 1, $offset);
|
||||
|
||||
$fieldlist=explode(',', $tabfield[$id]);
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -417,9 +417,9 @@ if ($id)
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused=0;
|
||||
$alabelisused = 0;
|
||||
|
||||
$fieldlist=explode(',', $tabfield[$id]);
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
@ -427,27 +427,27 @@ if ($id)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
$class="left";
|
||||
if ($fieldlist[$field]=='code') {
|
||||
$valuetoshow=$langs->trans("Code");
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
$class = "left";
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='nature') {
|
||||
$valuetoshow=$langs->trans("NatureOfJournal");
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
|
||||
if ($valuetoshow != '') {
|
||||
print '<td class="'.$class.'">';
|
||||
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
|
||||
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
|
||||
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
else print $valuetoshow;
|
||||
print '</td>';
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
@ -468,14 +468,14 @@ if ($id)
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val) != '')
|
||||
$obj->$val=GETPOST($val);
|
||||
$obj->$val = GETPOST($val);
|
||||
}
|
||||
}
|
||||
|
||||
$tmpaction = 'create';
|
||||
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
@ -487,31 +487,31 @@ if ($id)
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
|
||||
print '<tr><td colspan="7"> </td></tr>'; // Keep to have a line with enough height
|
||||
print '<tr><td colspan="7"> </td></tr>'; // Keep to have a line with enough height
|
||||
}
|
||||
|
||||
|
||||
|
||||
// List of available record in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
|
||||
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
|
||||
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
|
||||
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
|
||||
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -536,10 +536,10 @@ if ($id)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
$class="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
$showfield = 1; // By defaut
|
||||
$class = "left";
|
||||
$sortable = 1;
|
||||
$valuetoshow = '';
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
@ -547,24 +547,24 @@ if ($id)
|
||||
$align=$tmp['align'];
|
||||
$sortable=$tmp['sortable'];
|
||||
*/
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field]=='code') {
|
||||
$valuetoshow=$langs->trans("Code");
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='nature') {
|
||||
$valuetoshow=$langs->trans("NatureOfJournal");
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield) {
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
|
||||
}
|
||||
}
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
@ -578,12 +578,12 @@ if ($id)
|
||||
$obj = $db->fetch_object($resql);
|
||||
//print_r($obj);
|
||||
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
|
||||
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
|
||||
{
|
||||
$tmpaction='edit';
|
||||
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$tmpaction = 'edit';
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
@ -593,44 +593,44 @@ if ($id)
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
|
||||
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpaction = 'view';
|
||||
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$langs->load("accountancy");
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1;
|
||||
$class="left";
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
if ($valuetoshow=='all') {
|
||||
$valuetoshow=$langs->trans('All');
|
||||
$showfield = 1;
|
||||
$class = "left";
|
||||
$valuetoshow = $obj->{$fieldlist[$field]};
|
||||
if ($valuetoshow == 'all') {
|
||||
$valuetoshow = $langs->trans('All');
|
||||
}
|
||||
elseif ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
|
||||
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]});
|
||||
elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
|
||||
$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
|
||||
}
|
||||
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$valuetoshow=$langs->trans($obj->label);
|
||||
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$valuetoshow = $langs->trans($obj->label);
|
||||
}
|
||||
|
||||
$class='tddict';
|
||||
$class = 'tddict';
|
||||
// Show value for field
|
||||
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
|
||||
// Can an entry be erased or disabled ?
|
||||
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
|
||||
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
|
||||
if (isset($obj->code) && $id != 10) {
|
||||
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
|
||||
$iserasable = 0;
|
||||
@ -644,11 +644,11 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
$canbemodified=$iserasable;
|
||||
$canbemodified = $iserasable;
|
||||
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
|
||||
if ($param) $url .= '&'.$param;
|
||||
$url.='&';
|
||||
$url .= '&';
|
||||
|
||||
// Active
|
||||
print '<td class="nowrap center">';
|
||||
@ -708,10 +708,10 @@ $db->close();
|
||||
*/
|
||||
function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
{
|
||||
global $conf,$langs,$db;
|
||||
global $conf, $langs, $db;
|
||||
global $form, $mysoc;
|
||||
global $region_id;
|
||||
global $elementList,$sourceList,$localtax_typeList;
|
||||
global $elementList, $sourceList, $localtax_typeList;
|
||||
global $bc;
|
||||
|
||||
$formadmin = new FormAdmin($db);
|
||||
@ -722,20 +722,20 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
if ($fieldlist[$field] == 'nature')
|
||||
{
|
||||
print '<td>';
|
||||
print $form->selectarray('nature', $sourceList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
|
||||
print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
|
||||
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
|
||||
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
$size=''; $class='';
|
||||
if ($fieldlist[$field]=='code') $class='maxwidth100';
|
||||
if ($fieldlist[$field]=='label') $class='quatrevingtpercent';
|
||||
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
|
||||
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
$size = ''; $class = '';
|
||||
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
|
||||
if ($fieldlist[$field] == 'label') $class = 'quatrevingtpercent';
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
|
||||
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,14 +25,14 @@
|
||||
* \brief List operation of book keeping
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("accountancy"));
|
||||
@ -107,12 +107,12 @@ $formaccounting = new FormAccounting($db);
|
||||
$formother = new FormOther($db);
|
||||
$form = new Form($db);
|
||||
|
||||
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
|
||||
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
|
||||
{
|
||||
if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
|
||||
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
|
||||
{
|
||||
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
|
||||
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
|
||||
$res = $db->query($query);
|
||||
|
||||
if ($res->num_rows > 0) {
|
||||
@ -155,7 +155,7 @@ $arrayfields = array(
|
||||
|
||||
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
|
||||
|
||||
$listofformat=AccountancyExport::getType();
|
||||
$listofformat = AccountancyExport::getType();
|
||||
$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
|
||||
if (empty($listofformat[$formatexportset])) $formatexportset = 1;
|
||||
|
||||
@ -351,7 +351,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
|
||||
}
|
||||
|
||||
// Make a redirect to avoid to launch the delete later after a back button
|
||||
header("Location: list.php".($param?'?'.$param:''));
|
||||
header("Location: list.php".($param ? '?'.$param : ''));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@ -372,15 +372,15 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
}
|
||||
|
||||
header("Location: list.php?noreset=1".($param?'&'.$param:''));
|
||||
header("Location: list.php?noreset=1".($param ? '&'.$param : ''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($action == 'setreexport') {
|
||||
$setreexport = GETPOST('value', 'int');
|
||||
if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
|
||||
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
if ($conf->global->ACCOUNTING_REEXPORT == 1) {
|
||||
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
|
||||
} else {
|
||||
@ -421,27 +421,27 @@ $sql .= " t.piece_num,";
|
||||
$sql .= " t.date_creation,";
|
||||
$sql .= " t.tms as date_modification,";
|
||||
$sql .= " t.date_export";
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
|
||||
// Manage filter
|
||||
$sqlwhere = array ();
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.doc_date') {
|
||||
$sqlwhere[] = $key . '=\'' . $db->idate($value) . '\'';
|
||||
$sqlwhere[] = $key.'=\''.$db->idate($value).'\'';
|
||||
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
|
||||
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
|
||||
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
|
||||
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
|
||||
$sqlwhere[] = $key . '\'' . $db->escape($value) . '\'';
|
||||
$sqlwhere[] = $key.'\''.$db->escape($value).'\'';
|
||||
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
|
||||
$sqlwhere[] = $key . '=' . $value;
|
||||
$sqlwhere[] = $key.'='.$value;
|
||||
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
|
||||
$sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\'';
|
||||
$sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\'';
|
||||
} elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
|
||||
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
|
||||
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
|
||||
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
|
||||
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
|
||||
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
|
||||
} elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
|
||||
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
|
||||
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
|
||||
} elseif ($key == 't.credit' || $key == 't.debit') {
|
||||
$sqlwhere[] = natural_search($key, $value, 1, 1);
|
||||
} else {
|
||||
@ -449,14 +449,14 @@ if (count($filter) > 0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')';
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
|
||||
if ($conf->global->ACCOUNTING_REEXPORT == 0) {
|
||||
$sql .= " AND t.date_export IS NULL";
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' AND ', $sqlwhere);
|
||||
$sql .= ' AND '.implode(' AND ', $sqlwhere);
|
||||
}
|
||||
if (! empty($sortfield)) {
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
}
|
||||
//print $sql;
|
||||
@ -478,14 +478,14 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines, $formatexportset);
|
||||
|
||||
if (! empty($accountancyexport->errors))
|
||||
if (!empty($accountancyexport->errors))
|
||||
{
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Specify as export : update field date_export
|
||||
$error=0;
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
|
||||
if (is_array($object->lines))
|
||||
@ -494,13 +494,13 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
|
||||
{
|
||||
$now = dol_now();
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
$sql .= " SET date_export = '" . $db->idate($now) . "'";
|
||||
$sql .= " WHERE rowid = " . $movement->id;
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
|
||||
$sql .= " SET date_export = '".$db->idate($now)."'";
|
||||
$sql .= " WHERE rowid = ".$movement->id;
|
||||
|
||||
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG);
|
||||
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
if (!$result)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
@ -508,7 +508,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
|
||||
@ -550,10 +550,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql)
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
@ -574,7 +574,7 @@ if ($action == 'delmouv') {
|
||||
print $formconfirm;
|
||||
}
|
||||
if ($action == 'delbookkeepingyear') {
|
||||
$form_question = array ();
|
||||
$form_question = array();
|
||||
$delyear = GETPOST('delyear');
|
||||
$deljournal = GETPOST('deljournal');
|
||||
|
||||
@ -604,10 +604,10 @@ if ($action == 'delbookkeepingyear') {
|
||||
}
|
||||
|
||||
//$param=''; param started before
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
@ -620,27 +620,27 @@ if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
|
||||
else $buttonLabel = $langs->trans("ExportList");
|
||||
|
||||
// Button re-export
|
||||
if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
|
||||
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
|
||||
if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
|
||||
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
|
||||
} else {
|
||||
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
|
||||
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
|
||||
}
|
||||
$newcardbutton.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
|
||||
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
|
||||
|
||||
$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export);
|
||||
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
|
||||
|
||||
$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
|
||||
|
||||
$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
|
||||
|
||||
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
@ -720,111 +720,111 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Label operation
|
||||
if (! empty($arrayfields['t.label_operation']['checked']))
|
||||
if (!empty($arrayfields['t.label_operation']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
|
||||
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
|
||||
print '</td>';
|
||||
}
|
||||
// Debit
|
||||
if (! empty($arrayfields['t.debit']['checked']))
|
||||
if (!empty($arrayfields['t.debit']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Credit
|
||||
if (! empty($arrayfields['t.credit']['checked']))
|
||||
if (!empty($arrayfields['t.credit']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Lettering code
|
||||
if (! empty($arrayfields['t.lettering_code']['checked']))
|
||||
if (!empty($arrayfields['t.lettering_code']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . $search_lettering_code . '"/>';
|
||||
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
|
||||
print '</td>';
|
||||
}
|
||||
// Code journal
|
||||
if (! empty($arrayfields['t.code_journal']['checked']))
|
||||
if (!empty($arrayfields['t.code_journal']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
|
||||
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.$search_ledger_code.'"></td>';
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array('arrayfields'=>$arrayfields);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Date creation
|
||||
if (! empty($arrayfields['t.date_creation']['checked']))
|
||||
if (!empty($arrayfields['t.date_creation']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
if (!empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Date export
|
||||
if (! empty($arrayfields['t.date_export']['checked']))
|
||||
if (!empty($arrayfields['t.date_export']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From') . ' ';
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to') . ' ';
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Action column
|
||||
print '<td class="liste_titre center">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -833,12 +833,12 @@ $line = new BookKeepingLine();
|
||||
|
||||
// Loop on record
|
||||
// --------------------------------------------------------------------
|
||||
$i=0;
|
||||
$totalarray=array();
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) break; // Should not happen
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
$line->doc_date = $db->jdate($obj->doc_date);
|
||||
@ -1006,8 +1006,8 @@ print '</div>';
|
||||
|
||||
// TODO Replace this with mass delete action
|
||||
if ($user->rights->accounting->mouvements->supprimer_tous) {
|
||||
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
|
||||
print '<a class="butActionDelete" name="button_delmvt" href="' . $_SERVER["PHP_SELF"] . '?action=delbookkeepingyear' . ($param ? '&' . $param : '') . '">' . $langs->trans("DeleteMvt") . '</a>';
|
||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
||||
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
* \brief Class accountancy export
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
|
||||
/**
|
||||
* Manage the different format accountancy export
|
||||
@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
|
||||
class AccountancyExport
|
||||
{
|
||||
// Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
|
||||
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
|
||||
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
|
||||
public static $EXPORT_TYPE_AGIRIS = 10;
|
||||
public static $EXPORT_TYPE_EBP = 15;
|
||||
public static $EXPORT_TYPE_CEGID = 20;
|
||||
@ -83,7 +83,7 @@ class AccountancyExport
|
||||
|
||||
$this->db = &$db;
|
||||
$this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?"\n":($conf->global->ACCOUNTING_EXPORT_ENDLINE==1?"\n":"\r\n");
|
||||
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ class AccountancyExport
|
||||
*/
|
||||
private static function getFormatCode($type)
|
||||
{
|
||||
$formatcode = array (
|
||||
$formatcode = array(
|
||||
self::$EXPORT_TYPE_CONFIGURABLE => 'csv',
|
||||
self::$EXPORT_TYPE_CEGID => 'cegid',
|
||||
self::$EXPORT_TYPE_COALA => 'coala',
|
||||
@ -153,14 +153,14 @@ class AccountancyExport
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
return array (
|
||||
return array(
|
||||
'param' => array(
|
||||
self::$EXPORT_TYPE_CONFIGURABLE => array(
|
||||
'label' => $langs->trans('Modelcsv_configurable'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT)?'txt':$conf->global->ACCOUNTING_EXPORT_FORMAT,
|
||||
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV)?',':$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
|
||||
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?1:$conf->global->ACCOUNTING_EXPORT_ENDLINE,
|
||||
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE)?'%d%m%Y':$conf->global->ACCOUNTING_EXPORT_DATE,
|
||||
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
|
||||
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
|
||||
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
|
||||
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
|
||||
),
|
||||
self::$EXPORT_TYPE_CEGID => array(
|
||||
'label' => $langs->trans('Modelcsv_CEGID'),
|
||||
@ -209,11 +209,11 @@ class AccountancyExport
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
|
||||
),
|
||||
),
|
||||
'cr'=> array (
|
||||
'cr'=> array(
|
||||
'1' => $langs->trans("Unix"),
|
||||
'2' => $langs->trans("Windows")
|
||||
),
|
||||
'format' => array (
|
||||
'format' => array(
|
||||
'csv' => $langs->trans("csv"),
|
||||
'txt' => $langs->trans("txt")
|
||||
),
|
||||
@ -231,13 +231,13 @@ class AccountancyExport
|
||||
public function export(&$TData, $formatexportset)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
|
||||
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
|
||||
|
||||
// Define name of file to save
|
||||
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
|
||||
$type_export = 'general_ledger';
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
|
||||
switch ($formatexportset) {
|
||||
@ -303,13 +303,13 @@ class AccountancyExport
|
||||
$separator = ";";
|
||||
$end_line = "\n";
|
||||
|
||||
print $date . $separator;
|
||||
print $line->code_journal . $separator;
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print length_accounta($line->subledger_account) . $separator;
|
||||
print $line->sens . $separator;
|
||||
print price($line->montant) . $separator;
|
||||
print $line->label_operation . $separator;
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
print $line->sens.$separator;
|
||||
print price($line->montant).$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print $line->doc_ref;
|
||||
print $end_line;
|
||||
}
|
||||
@ -328,22 +328,22 @@ class AccountancyExport
|
||||
$separator = ";";
|
||||
$end_line = "\n";
|
||||
|
||||
print $line->code_journal . $separator;
|
||||
print $date . $separator;
|
||||
print $line->piece_num . $separator;
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print '' . $separator;
|
||||
print $line->label_operation . $separator;
|
||||
print $date . $separator;
|
||||
if ($line->sens=='D') {
|
||||
print price($line->montant) . $separator;
|
||||
print '' . $separator;
|
||||
}elseif ($line->sens=='C') {
|
||||
print '' . $separator;
|
||||
print price($line->montant) . $separator;
|
||||
print $line->code_journal.$separator;
|
||||
print $date.$separator;
|
||||
print $line->piece_num.$separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
print ''.$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print $date.$separator;
|
||||
if ($line->sens == 'D') {
|
||||
print price($line->montant).$separator;
|
||||
print ''.$separator;
|
||||
}elseif ($line->sens == 'C') {
|
||||
print ''.$separator;
|
||||
print price($line->montant).$separator;
|
||||
}
|
||||
print $line->doc_ref . $separator;
|
||||
print $line->label_operation . $separator;
|
||||
print $line->doc_ref.$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
@ -362,15 +362,15 @@ class AccountancyExport
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
print $date . $separator;
|
||||
print $line->code_journal . $separator;
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print $line->piece_num . $separator;
|
||||
print $line->doc_ref . $separator;
|
||||
print price($line->debit) . $separator;
|
||||
print price($line->credit) . $separator;
|
||||
print 'E' . $separator;
|
||||
print length_accountg($line->subledger_account) . $separator;
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
print $line->piece_num.$separator;
|
||||
print $line->doc_ref.$separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
print 'E'.$separator;
|
||||
print length_accountg($line->subledger_account).$separator;
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
@ -389,26 +389,26 @@ class AccountancyExport
|
||||
$end_line = "\n";
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
print $line->piece_num . $separator;
|
||||
print $line->piece_num.$separator;
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
print $date . $separator;
|
||||
print $date.$separator;
|
||||
|
||||
if (empty($line->subledger_account)) {
|
||||
print 'G' . $separator;
|
||||
print length_accounta($line->numero_compte) . $separator;
|
||||
print 'G'.$separator;
|
||||
print length_accounta($line->numero_compte).$separator;
|
||||
} else {
|
||||
if (substr($line->numero_compte, 0, 3) == '411') {
|
||||
print 'C' . $separator;
|
||||
print 'C'.$separator;
|
||||
}
|
||||
if (substr($line->numero_compte, 0, 3) == '401') {
|
||||
print 'F' . $separator;
|
||||
print 'F'.$separator;
|
||||
}
|
||||
print length_accountg($line->subledger_account) . $separator;
|
||||
print length_accountg($line->subledger_account).$separator;
|
||||
}
|
||||
|
||||
print price($line->debit) . $separator;
|
||||
print price($line->credit) . $separator;
|
||||
print dol_trunc($line->label_operation, 32) . $separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
print dol_trunc($line->label_operation, 32).$separator;
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
@ -423,23 +423,23 @@ class AccountancyExport
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$end_line ="\r\n";
|
||||
$end_line = "\r\n";
|
||||
|
||||
$i = 1;
|
||||
$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
|
||||
foreach ($TData as $data) {
|
||||
$code_compta = $data->numero_compte;
|
||||
if (! empty($data->subledger_account))
|
||||
if (!empty($data->subledger_account))
|
||||
$code_compta = $data->subledger_account;
|
||||
|
||||
$Tab = array ();
|
||||
$Tab = array();
|
||||
$Tab['num_ecriture'] = str_pad($i, 5);
|
||||
$Tab['code_journal'] = str_pad($data->code_journal, 2);
|
||||
$Tab['date_ecriture'] = $date_ecriture;
|
||||
$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
|
||||
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
|
||||
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
|
||||
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . dol_string_unaccent($data->label_operation), 25), 25);
|
||||
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
|
||||
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
|
||||
$Tab['type_montant'] = str_pad($data->sens, 1);
|
||||
$Tab['vide'] = str_repeat(' ', 18);
|
||||
@ -449,7 +449,7 @@ class AccountancyExport
|
||||
$Tab['end_line'] = $end_line;
|
||||
|
||||
print implode($Tab);
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,17 +463,17 @@ class AccountancyExport
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$end_line ="\r\n";
|
||||
$end_line = "\r\n";
|
||||
|
||||
//We should use dol_now function not time however this is wrong date to transfert in accounting
|
||||
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
|
||||
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
|
||||
foreach ($TData as $data) {
|
||||
$code_compta = $data->numero_compte;
|
||||
if (! empty($data->subledger_account))
|
||||
if (!empty($data->subledger_account))
|
||||
$code_compta = $data->subledger_account;
|
||||
|
||||
$Tab = array ();
|
||||
$Tab = array();
|
||||
$Tab['type_ligne'] = 'M';
|
||||
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
|
||||
$Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
|
||||
@ -484,19 +484,19 @@ class AccountancyExport
|
||||
//$Tab['date_ecriture'] = $date_ecriture;
|
||||
$Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
|
||||
$Tab['filler'] = ' ';
|
||||
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 20), 20);
|
||||
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
|
||||
$Tab['sens'] = $data->sens; // C or D
|
||||
$Tab['signe_montant'] = '+';
|
||||
|
||||
//elarifr le montant doit etre en centimes sans point decimal !
|
||||
$Tab['montant'] = str_pad(abs($data->montant*100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
|
||||
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
|
||||
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
|
||||
$Tab['contrepartie'] = str_repeat(' ', 8);
|
||||
|
||||
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
|
||||
if (! empty($data->date_echeance))
|
||||
if (!empty($data->date_echeance))
|
||||
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
|
||||
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
|
||||
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
|
||||
else
|
||||
$Tab['date_echeance'] = '000000';
|
||||
|
||||
@ -551,20 +551,20 @@ class AccountancyExport
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->id . $separator;
|
||||
print $date . $separator;
|
||||
print $line->code_journal . $separator;
|
||||
print $line->id.$separator;
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
if (empty($line->subledger_account)) {
|
||||
print $line->numero_compte . $separator;
|
||||
print $line->numero_compte.$separator;
|
||||
} else {
|
||||
print $line->subledger_account . $separator;
|
||||
print $line->subledger_account.$separator;
|
||||
}
|
||||
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
|
||||
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"' . $separator;
|
||||
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
|
||||
print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
|
||||
print price2num(abs($line->montant)).$separator;
|
||||
print $line->sens.$separator;
|
||||
print $date . $separator;
|
||||
print $date.$separator;
|
||||
//print 'EUR';
|
||||
print $end_line;
|
||||
}
|
||||
@ -586,25 +586,25 @@ class AccountancyExport
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->piece_num . $separator;
|
||||
print self::toAnsi($line->label_operation) . $separator;
|
||||
print $date . $separator;
|
||||
print self::toAnsi($line->label_operation) . $separator;
|
||||
print $line->piece_num.$separator;
|
||||
print self::toAnsi($line->label_operation).$separator;
|
||||
print $date.$separator;
|
||||
print self::toAnsi($line->label_operation).$separator;
|
||||
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print self::toAnsi($line->label_compte) . $separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
print self::toAnsi($line->label_compte).$separator;
|
||||
} else {
|
||||
print length_accounta($line->subledger_account) . $separator;
|
||||
print self::toAnsi($line->subledger_label) . $separator;
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
print self::toAnsi($line->subledger_label).$separator;
|
||||
}
|
||||
|
||||
print self::toAnsi($line->doc_ref) . $separator;
|
||||
print price($line->debit) . $separator;
|
||||
print price($line->credit) . $separator;
|
||||
print price($line->montant) . $separator;
|
||||
print $line->sens . $separator;
|
||||
print $line->lettering_code . $separator;
|
||||
print self::toAnsi($line->doc_ref).$separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
print price($line->montant).$separator;
|
||||
print $line->sens.$separator;
|
||||
print $line->lettering_code.$separator;
|
||||
print $line->code_journal;
|
||||
print $end_line;
|
||||
}
|
||||
@ -625,17 +625,17 @@ class AccountancyExport
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
|
||||
print $date . $separator;
|
||||
print $line->code_journal . $separator;
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
} else {
|
||||
print length_accounta($line->subledger_account) . $separator;
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
}
|
||||
print $line->doc_ref . $separator;
|
||||
print $line->label_operation . $separator;
|
||||
print price($line->debit) . $separator;
|
||||
print price($line->credit) . $separator;
|
||||
print $line->doc_ref.$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
|
||||
print $end_line;
|
||||
}
|
||||
@ -668,7 +668,7 @@ class AccountancyExport
|
||||
$tab[] = price2num($line->montant);
|
||||
$tab[] = $line->code_journal;
|
||||
|
||||
print implode($separator, $tab) . $this->end_line;
|
||||
print implode($separator, $tab).$this->end_line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -683,23 +683,23 @@ class AccountancyExport
|
||||
$separator = "\t";
|
||||
$end_line = "\n";
|
||||
|
||||
print "JournalCode" . $separator;
|
||||
print "JournalLib" . $separator;
|
||||
print "EcritureNum" . $separator;
|
||||
print "EcritureDate" . $separator;
|
||||
print "CompteNum" . $separator;
|
||||
print "CompteLib" . $separator;
|
||||
print "CompAuxNum" . $separator;
|
||||
print "CompAuxLib" . $separator;
|
||||
print "PieceRef" . $separator;
|
||||
print "PieceDate" . $separator;
|
||||
print "EcritureLib" . $separator;
|
||||
print "Debit" . $separator;
|
||||
print "Credit" . $separator;
|
||||
print "EcritureLet" . $separator;
|
||||
print "DateLet" . $separator;
|
||||
print "ValidDate" . $separator;
|
||||
print "Montantdevise" . $separator;
|
||||
print "JournalCode".$separator;
|
||||
print "JournalLib".$separator;
|
||||
print "EcritureNum".$separator;
|
||||
print "EcritureDate".$separator;
|
||||
print "CompteNum".$separator;
|
||||
print "CompteLib".$separator;
|
||||
print "CompAuxNum".$separator;
|
||||
print "CompAuxLib".$separator;
|
||||
print "PieceRef".$separator;
|
||||
print "PieceDate".$separator;
|
||||
print "EcritureLib".$separator;
|
||||
print "Debit".$separator;
|
||||
print "Credit".$separator;
|
||||
print "EcritureLet".$separator;
|
||||
print "DateLet".$separator;
|
||||
print "ValidDate".$separator;
|
||||
print "Montantdevise".$separator;
|
||||
print "Idevise";
|
||||
print $end_line;
|
||||
|
||||
@ -709,55 +709,55 @@ class AccountancyExport
|
||||
$date_valid = dol_print_date($line->date_validated, '%d%m%Y');
|
||||
|
||||
// FEC:JournalCode
|
||||
print $line->code_journal . $separator;
|
||||
print $line->code_journal.$separator;
|
||||
|
||||
// FEC:JournalLib
|
||||
print $line->journal_label . $separator;
|
||||
print $line->journal_label.$separator;
|
||||
|
||||
// FEC:EcritureNum
|
||||
print $line->piece_num . $separator;
|
||||
print $line->piece_num.$separator;
|
||||
|
||||
// FEC:EcritureDate
|
||||
print $date_creation . $separator;
|
||||
print $date_creation.$separator;
|
||||
|
||||
// FEC:CompteNum
|
||||
print $line->numero_compte . $separator;
|
||||
print $line->numero_compte.$separator;
|
||||
|
||||
// FEC:CompteLib
|
||||
print $line->label_compte . $separator;
|
||||
print $line->label_compte.$separator;
|
||||
|
||||
// FEC:CompAuxNum
|
||||
print $line->subledger_account . $separator;
|
||||
print $line->subledger_account.$separator;
|
||||
|
||||
// FEC:CompAuxLib
|
||||
print $line->subledger_label . $separator;
|
||||
print $line->subledger_label.$separator;
|
||||
|
||||
// FEC:PieceRef
|
||||
print $line->doc_ref . $separator;
|
||||
print $line->doc_ref.$separator;
|
||||
|
||||
// FEC:PieceDate
|
||||
print $date_doc . $separator;
|
||||
print $date_doc.$separator;
|
||||
|
||||
// FEC:EcritureLib
|
||||
print $line->label_operation . $separator;
|
||||
print $line->label_operation.$separator;
|
||||
|
||||
// FEC:Debit
|
||||
print price2num($line->debit) . $separator;
|
||||
print price2num($line->debit).$separator;
|
||||
|
||||
// FEC:Credit
|
||||
print price2num($line->credit) . $separator;
|
||||
print price2num($line->credit).$separator;
|
||||
|
||||
// FEC:EcritureLet
|
||||
print $line->lettering_code . $separator;
|
||||
print $line->lettering_code.$separator;
|
||||
|
||||
// FEC:DateLet
|
||||
print $line->date_lettering . $separator;
|
||||
print $line->date_lettering.$separator;
|
||||
|
||||
// FEC:ValidDate
|
||||
print $date_valid . $separator;
|
||||
print $date_valid.$separator;
|
||||
|
||||
// FEC:Montantdevise
|
||||
print $line->multicurrency_amount . $separator;
|
||||
print $line->multicurrency_amount.$separator;
|
||||
|
||||
// FEC:Idevise
|
||||
print $line->multicurrency_code;
|
||||
@ -785,121 +785,121 @@ class AccountancyExport
|
||||
// Print header line
|
||||
print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
|
||||
print $this->end_line;
|
||||
$thisPieceNum= "";
|
||||
$thisPieceAccountNr= "";
|
||||
$aSize= count($objectLines);
|
||||
$thisPieceNum = "";
|
||||
$thisPieceAccountNr = "";
|
||||
$aSize = count($objectLines);
|
||||
foreach ($objectLines as $aIndex=>$line)
|
||||
{
|
||||
$sammelBuchung= false;
|
||||
if ($aIndex-2 >= 0 && $objectLines[$aIndex-2]->piece_num == $line->piece_num)
|
||||
$sammelBuchung = false;
|
||||
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung= true;
|
||||
$sammelBuchung = true;
|
||||
}
|
||||
elseif ($aIndex+2 < $aSize && $objectLines[$aIndex+2]->piece_num == $line->piece_num)
|
||||
elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung= true;
|
||||
$sammelBuchung = true;
|
||||
}
|
||||
elseif ($aIndex+1 < $aSize
|
||||
&& $objectLines[$aIndex+1]->piece_num == $line->piece_num
|
||||
&& $aIndex-1 < $aSize
|
||||
&& $objectLines[$aIndex-1]->piece_num == $line->piece_num
|
||||
elseif ($aIndex + 1 < $aSize
|
||||
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num
|
||||
&& $aIndex - 1 < $aSize
|
||||
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num
|
||||
)
|
||||
{
|
||||
$sammelBuchung= true;
|
||||
$sammelBuchung = true;
|
||||
}
|
||||
|
||||
//Blg
|
||||
print $line->piece_num . $this->separator;
|
||||
print $line->piece_num.$this->separator;
|
||||
|
||||
// Datum
|
||||
$date = dol_print_date($line->doc_date, '%d.%m.%Y');
|
||||
print $date . $this->separator;
|
||||
print $date.$this->separator;
|
||||
|
||||
// Kto
|
||||
print length_accountg($line->numero_compte) . $this->separator;
|
||||
print length_accountg($line->numero_compte).$this->separator;
|
||||
// S/H
|
||||
if ($line->sens == 'D')
|
||||
{
|
||||
print 'S' . $this->separator;
|
||||
print 'S'.$this->separator;
|
||||
}
|
||||
else
|
||||
{
|
||||
print 'H' . $this->separator;
|
||||
print 'H'.$this->separator;
|
||||
}
|
||||
//Grp
|
||||
print self::trunc($line->code_journal, 1) . $this->separator;
|
||||
print self::trunc($line->code_journal, 1).$this->separator;
|
||||
// GKto
|
||||
if (empty($line->code_tiers))
|
||||
{
|
||||
if ($line->piece_num == $thisPieceNum)
|
||||
{
|
||||
print length_accounta($thisPieceAccountNr) . $this->separator;
|
||||
print length_accounta($thisPieceAccountNr).$this->separator;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "div" . $this->separator;
|
||||
print "div".$this->separator;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print length_accounta($line->code_tiers) . $this->separator;
|
||||
print length_accounta($line->code_tiers).$this->separator;
|
||||
}
|
||||
//SId
|
||||
print $this->separator;
|
||||
//SIdx
|
||||
print "0" . $this->separator;
|
||||
print "0".$this->separator;
|
||||
//KIdx
|
||||
print "0" . $this->separator;
|
||||
print "0".$this->separator;
|
||||
//BTyp
|
||||
print "0" . $this->separator;
|
||||
print "0".$this->separator;
|
||||
|
||||
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
|
||||
if ($sammelBuchung)
|
||||
{
|
||||
print "2" . $this->separator;
|
||||
print "2".$this->separator;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "1" . $this->separator;
|
||||
print "1".$this->separator;
|
||||
}
|
||||
// Code
|
||||
print '""' . $this->separator;
|
||||
print '""'.$this->separator;
|
||||
// Netto
|
||||
if ($line->montant >= 0)
|
||||
{
|
||||
print $line->montant . $this->separator;
|
||||
print $line->montant.$this->separator;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $line->montant*-1 . $this->separator;
|
||||
print $line->montant * -1.$this->separator;
|
||||
}
|
||||
// Steuer
|
||||
print "0.00" . $this->separator;
|
||||
print "0.00".$this->separator;
|
||||
// FW-Betrag
|
||||
print "0.00" . $this->separator;
|
||||
print "0.00".$this->separator;
|
||||
// Tx1
|
||||
$line1= self::toAnsi($line->label_compte, 29);
|
||||
$line1 = self::toAnsi($line->label_compte, 29);
|
||||
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
|
||||
{
|
||||
$line1= "";
|
||||
$line1 = "";
|
||||
}
|
||||
$line2= self::toAnsi($line->doc_ref, 29);
|
||||
$line2 = self::toAnsi($line->doc_ref, 29);
|
||||
if (strlen($line1) == 0)
|
||||
{
|
||||
$line1= $line2;
|
||||
$line2= "";
|
||||
$line1 = $line2;
|
||||
$line2 = "";
|
||||
}
|
||||
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
|
||||
{
|
||||
$line1= $line1 . ' / ' . $line2;
|
||||
$line2= "";
|
||||
$line1 = $line1.' / '.$line2;
|
||||
$line2 = "";
|
||||
}
|
||||
|
||||
print '"' . self::toAnsi($line1). '"' . $this->separator;
|
||||
print '"'.self::toAnsi($line1).'"'.$this->separator;
|
||||
// Tx2
|
||||
print '"' . self::toAnsi($line2). '"' . $this->separator;
|
||||
print '"'.self::toAnsi($line2).'"'.$this->separator;
|
||||
//PkKey
|
||||
print "0" . $this->separator;
|
||||
print "0".$this->separator;
|
||||
//OpId
|
||||
print $this->separator;
|
||||
|
||||
@ -910,8 +910,8 @@ class AccountancyExport
|
||||
|
||||
if ($line->piece_num !== $thisPieceNum)
|
||||
{
|
||||
$thisPieceNum= $line->piece_num;
|
||||
$thisPieceAccountNr= $line->numero_compte;
|
||||
$thisPieceNum = $line->piece_num;
|
||||
$thisPieceAccountNr = $line->numero_compte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -932,23 +932,23 @@ class AccountancyExport
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
|
||||
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
||||
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
|
||||
|
||||
// TYPE
|
||||
$type_enregistrement = 'E'; // For write movement
|
||||
print $type_enregistrement . $separator;
|
||||
print $type_enregistrement.$separator;
|
||||
// JNAL
|
||||
print substr($line->code_journal, 0, 2) . $separator;
|
||||
print substr($line->code_journal, 0, 2).$separator;
|
||||
// NECR
|
||||
print $line->id . $separator;
|
||||
print $line->id.$separator;
|
||||
// NPIE
|
||||
print $line->piece_num . $separator;
|
||||
print $line->piece_num.$separator;
|
||||
// DATP
|
||||
print $date_document . $separator;
|
||||
print $date_document.$separator;
|
||||
// LIBE
|
||||
print $line->label_operation . $separator;
|
||||
print $line->label_operation.$separator;
|
||||
// DATH
|
||||
print $line->date_lim_reglement . $separator;
|
||||
print $line->date_lim_reglement.$separator;
|
||||
// CNPI
|
||||
if ($line->doc_type == 'supplier_invoice') {
|
||||
if ($line->montant < 0) {
|
||||
@ -965,7 +965,7 @@ class AccountancyExport
|
||||
} else {
|
||||
$nature_piece = '';
|
||||
}
|
||||
print $nature_piece . $separator;
|
||||
print $nature_piece.$separator;
|
||||
// RACI
|
||||
/*
|
||||
if (! empty($line->subledger_account)) {
|
||||
@ -983,28 +983,28 @@ class AccountancyExport
|
||||
*/
|
||||
print $separator; // deprecated CPTG & CPTA use instead
|
||||
// MONT
|
||||
print price(abs($line->montant), 0, '', 1, 2) . $separator;
|
||||
print price(abs($line->montant), 0, '', 1, 2).$separator;
|
||||
// CODC
|
||||
print $line->sens . $separator;
|
||||
print $line->sens.$separator;
|
||||
// CPTG
|
||||
print length_accountg($line->numero_compte) . $separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
// DATE
|
||||
print $date_creation . $separator;
|
||||
print $date_creation.$separator;
|
||||
// CLET
|
||||
print $line->lettering_code . $separator;
|
||||
print $line->lettering_code.$separator;
|
||||
// DATL
|
||||
print $line->date_lettering . $separator;
|
||||
print $line->date_lettering.$separator;
|
||||
// CPTA
|
||||
if (! empty($line->subledger_account)) {
|
||||
print length_accounta($line->subledger_account) . $separator;
|
||||
if (!empty($line->subledger_account)) {
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
} else {
|
||||
print $separator;
|
||||
}
|
||||
// CNAT
|
||||
if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) {
|
||||
print 'F' . $separator;
|
||||
} elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) {
|
||||
print 'C' . $separator;
|
||||
if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
|
||||
print 'F'.$separator;
|
||||
} elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
|
||||
print 'C'.$separator;
|
||||
} else {
|
||||
print $separator;
|
||||
}
|
||||
@ -1017,17 +1017,17 @@ class AccountancyExport
|
||||
// DATV
|
||||
print $separator;
|
||||
// REFD
|
||||
print $line->doc_ref . $separator;
|
||||
print $line->doc_ref.$separator;
|
||||
// CODH
|
||||
print $separator;
|
||||
// NSEQ
|
||||
print $separator;
|
||||
// MTDV
|
||||
print '0' . $separator;
|
||||
print '0'.$separator;
|
||||
// CODV
|
||||
print $separator;
|
||||
// TXDV
|
||||
print '0' . $separator;
|
||||
print '0'.$separator;
|
||||
// MOPM
|
||||
print $separator;
|
||||
// BONP
|
||||
@ -1066,43 +1066,43 @@ class AccountancyExport
|
||||
/*
|
||||
* Charlemagne export need header
|
||||
*/
|
||||
print $langs->transnoentitiesnoconv('Date') . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator;
|
||||
print $langs->transnoentitiesnoconv('Amount') . $separator;
|
||||
print 'S' . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator;
|
||||
print $langs->transnoentitiesnoconv('Date').$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
|
||||
print $langs->transnoentitiesnoconv('Amount').$separator;
|
||||
print 'S'.$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
|
||||
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
|
||||
print $end_line;
|
||||
|
||||
foreach($objectLines as $line) {
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%Y%m%d');
|
||||
print $date . $separator; //Date
|
||||
print $date.$separator; //Date
|
||||
|
||||
print self::trunc($line->code_journal, 6) . $separator; //Journal code
|
||||
print self::trunc($line->code_journal, 6).$separator; //Journal code
|
||||
|
||||
if(!empty($line->subledger_account)) $account = $line->subledger_account;
|
||||
if (!empty($line->subledger_account)) $account = $line->subledger_account;
|
||||
else $account = $line->numero_compte;
|
||||
print self::trunc($account, 15) . $separator;//Account number
|
||||
print self::trunc($account, 15).$separator; //Account number
|
||||
|
||||
print self::trunc($line->label_compte, 60) . $separator;//Account label
|
||||
print self::trunc($line->doc_ref, 20) . $separator;//Piece
|
||||
print self::trunc($line->label_operation, 60) . $separator;//Operation label
|
||||
print price(abs($line->montant)) . $separator;//Amount
|
||||
print $line->sens . $separator;//Direction
|
||||
print $separator;//Analytic
|
||||
print $separator;//Analytic
|
||||
print $separator;//Analytic
|
||||
print $separator;//Analytic
|
||||
print $separator;//Analytic
|
||||
print $separator;//Analytic
|
||||
print self::trunc($line->label_compte, 60).$separator; //Account label
|
||||
print self::trunc($line->doc_ref, 20).$separator; //Piece
|
||||
print self::trunc($line->label_operation, 60).$separator; //Operation label
|
||||
print price(abs($line->montant)).$separator; //Amount
|
||||
print $line->sens.$separator; //Direction
|
||||
print $separator; //Analytic
|
||||
print $separator; //Analytic
|
||||
print $separator; //Analytic
|
||||
print $separator; //Analytic
|
||||
print $separator; //Analytic
|
||||
print $separator; //Analytic
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
@ -1129,10 +1129,10 @@ class AccountancyExport
|
||||
*/
|
||||
public static function toAnsi($str, $size = -1)
|
||||
{
|
||||
$retVal= dol_string_nohtmltag($str, 1, 'Windows-1251');
|
||||
$retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
|
||||
if ($retVal >= 0 && $size >= 0)
|
||||
{
|
||||
$retVal= mb_substr($retVal, 0, $size, 'Windows-1251');
|
||||
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
|
||||
}
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
@ -29,17 +29,17 @@
|
||||
* \brief Page with expense reports journal
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors"));
|
||||
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "trips", "errors"));
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -75,13 +75,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
$pastmonthyear--;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
@ -91,62 +91,62 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
|
||||
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, ";
|
||||
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
|
||||
$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
|
||||
$sql .= " WHERE er.fk_statut > 0";
|
||||
$sql .= " AND erd.fk_code_ventilation > 0";
|
||||
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'";
|
||||
// Already in bookkeeping or not
|
||||
if ($in_bookkeeping == 'already')
|
||||
{
|
||||
$sql .= " AND er.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
|
||||
$sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
|
||||
}
|
||||
if ($in_bookkeeping == 'notyet')
|
||||
{
|
||||
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
|
||||
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
|
||||
}
|
||||
$sql .= " ORDER BY er.date_debut";
|
||||
|
||||
dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$taber = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$def_tva = array ();
|
||||
$tabttc = array ();
|
||||
$tablocaltax1 = array ();
|
||||
$tablocaltax2 = array ();
|
||||
$tabuser = array ();
|
||||
$taber = array();
|
||||
$tabht = array();
|
||||
$tabtva = array();
|
||||
$def_tva = array();
|
||||
$tabttc = array();
|
||||
$tablocaltax1 = array();
|
||||
$tablocaltax2 = array();
|
||||
$tabuser = array();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
// Variables
|
||||
$account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined';
|
||||
$account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
|
||||
$account_salary = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined';
|
||||
$account_vat = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// Controls
|
||||
$compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
|
||||
$compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
|
||||
$compta_fees = $obj->compte;
|
||||
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
|
||||
$compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
|
||||
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
|
||||
{
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
|
||||
}
|
||||
|
||||
$taber[$obj->rowid]["date"] = $db->jdate($obj->de);
|
||||
@ -155,24 +155,24 @@ if ($result) {
|
||||
$taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid;
|
||||
|
||||
// Avoid warnings
|
||||
if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
if (!isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0;
|
||||
if (!isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0;
|
||||
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
|
||||
$tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
|
||||
$tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
|
||||
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
|
||||
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
|
||||
$tabuser[$obj->rowid] = array (
|
||||
$tabuser[$obj->rowid] = array(
|
||||
'id' => $obj->uid,
|
||||
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
|
||||
'user_accountancy_code' => $obj->user_accountancy_account
|
||||
);
|
||||
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -193,7 +193,7 @@ if ($action == 'writebookkeeping') {
|
||||
$db->begin();
|
||||
|
||||
// Thirdparty
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
@ -244,7 +244,7 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Fees
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
foreach ($tabht[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
@ -295,10 +295,10 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// VAT
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
$listoftax=array(0, 1, 2);
|
||||
foreach($listoftax as $numtax)
|
||||
$listoftax = array(0, 1, 2);
|
||||
foreach ($listoftax as $numtax)
|
||||
{
|
||||
$arrayofvat = $tabtva;
|
||||
if ($numtax == 1) $arrayofvat = $tablocaltax1;
|
||||
@ -362,7 +362,7 @@ if ($action == 'writebookkeeping') {
|
||||
setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
|
||||
}
|
||||
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,21 +392,21 @@ if ($action == 'writebookkeeping') {
|
||||
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||
}
|
||||
|
||||
$action='';
|
||||
$action = '';
|
||||
|
||||
// Must reload data, so we make a redirect
|
||||
if (count($tabpay) != $error)
|
||||
{
|
||||
$param='id_journal='.$id_journal;
|
||||
$param.='&date_startday='.$date_startday;
|
||||
$param.='&date_startmonth='.$date_startmonth;
|
||||
$param.='&date_startyear='.$date_startyear;
|
||||
$param.='&date_endday='.$date_endday;
|
||||
$param.='&date_endmonth='.$date_endmonth;
|
||||
$param.='&date_endyear='.$date_endyear;
|
||||
$param.='&in_bookkeeping='.$in_bookkeeping;
|
||||
$param = 'id_journal='.$id_journal;
|
||||
$param .= '&date_startday='.$date_startday;
|
||||
$param .= '&date_startmonth='.$date_startmonth;
|
||||
$param .= '&date_startyear='.$date_startyear;
|
||||
$param .= '&date_endday='.$date_endday;
|
||||
$param .= '&date_endmonth='.$date_endmonth;
|
||||
$param .= '&date_endyear='.$date_endyear;
|
||||
$param .= '&in_bookkeeping='.$in_bookkeeping;
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -426,15 +426,15 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
$filename = 'journal';
|
||||
$type_export = 'journal';
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
// CSV header line
|
||||
print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep;
|
||||
print '"' . $langs->transnoentitiesnoconv("Piece") . '"' . $sep;
|
||||
print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep;
|
||||
print '"' . $langs->transnoentitiesnoconv("LabelOperation") . '"' . $sep;
|
||||
print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep;
|
||||
print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("Piece").'"'.$sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("LabelOperation").'"'.$sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep;
|
||||
print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep;
|
||||
print "\n";
|
||||
|
||||
foreach ($taber as $key => $val) {
|
||||
@ -486,18 +486,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
if (empty($action) || $action == 'view') {
|
||||
llxHeader('', $langs->trans("ExpenseReportsJournal"));
|
||||
|
||||
$nom = $langs->trans("ExpenseReportsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nom = $langs->trans("ExpenseReportsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate=dol_now();
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
$builddate = dol_now();
|
||||
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||
|
||||
@ -508,13 +508,13 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
|
||||
if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
|
||||
}
|
||||
else {
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@ -543,13 +543,13 @@ if (empty($action) || $action == 'view') {
|
||||
print '<div class="div-table-responsive">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print '<td class="right">' . $langs->trans("Debit") . "</td>";
|
||||
print '<td class="right">' . $langs->trans("Credit") . "</td>";
|
||||
print "<td>".$langs->trans("Date")."</td>";
|
||||
print "<td>".$langs->trans("Piece").' ('.$langs->trans("ExpenseReportRef").")</td>";
|
||||
print "<td>".$langs->trans("AccountAccounting")."</td>";
|
||||
print "<td>".$langs->trans("SubledgerAccount")."</td>";
|
||||
print "<td>".$langs->trans("LabelOperation")."</td>";
|
||||
print '<td class="right">'.$langs->trans("Debit")."</td>";
|
||||
print '<td class="right">'.$langs->trans("Credit")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$r = '';
|
||||
@ -572,8 +572,8 @@ if (empty($action) || $action == 'view') {
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Fees -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
|
||||
$userstatic->id = $tabuser[$key]['id'];
|
||||
$userstatic->name = $tabuser[$key]['name'];
|
||||
// Account
|
||||
@ -590,9 +590,9 @@ if (empty($action) || $action == 'view') {
|
||||
print '</td>';
|
||||
$userstatic->id = $tabuser[$key]['id'];
|
||||
$userstatic->name = $tabuser[$key]['name'];
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."</td>";
|
||||
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
|
||||
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
@ -604,8 +604,8 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Thirdparty -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
|
||||
@ -624,9 +624,9 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
else print $accountoshow;
|
||||
print '</td>';
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
|
||||
print '<td class="right nowraponall">'.($mt < 0 ? -price(-$mt) : '')."</td>";
|
||||
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
|
||||
@ -29,17 +29,17 @@
|
||||
* \brief Page with purchases journal
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
|
||||
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors"));
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -60,12 +60,12 @@ if ($user->socid > 0)
|
||||
accessforbidden();
|
||||
|
||||
$hookmanager->initHooks(array('purchasesjournal'));
|
||||
$parameters=array();
|
||||
$parameters = array();
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
|
||||
@ -80,13 +80,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
$pastmonthyear--;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
@ -96,53 +96,53 @@ $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_sup
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " WHERE f.fk_statut > 0";
|
||||
$sql .= " AND fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
|
||||
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")";
|
||||
} else {
|
||||
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")";
|
||||
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")";
|
||||
}
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
// Already in bookkeeping or not
|
||||
if ($in_bookkeeping == 'already')
|
||||
{
|
||||
$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
|
||||
$sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
|
||||
}
|
||||
if ($in_bookkeeping == 'notyet')
|
||||
{
|
||||
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
|
||||
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
|
||||
}
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$def_tva = array ();
|
||||
$tabttc = array ();
|
||||
$tablocaltax1 = array ();
|
||||
$tablocaltax2 = array ();
|
||||
$tabcompany = array ();
|
||||
$tabfac = array();
|
||||
$tabht = array();
|
||||
$tabtva = array();
|
||||
$def_tva = array();
|
||||
$tabttc = array();
|
||||
$tablocaltax1 = array();
|
||||
$tablocaltax2 = array();
|
||||
$tabcompany = array();
|
||||
$tabother = array();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
// Variables
|
||||
$cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
|
||||
$cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// Controls
|
||||
@ -151,21 +151,21 @@ if ($result) {
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
|
||||
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
|
||||
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
|
||||
}
|
||||
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_counterpart_tva_npr = (! empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined';
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined';
|
||||
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
|
||||
{
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
|
||||
}
|
||||
|
||||
$line = new SupplierInvoiceLine($db);
|
||||
@ -173,31 +173,31 @@ if ($result) {
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')';
|
||||
$tabfac[$obj->rowid]["refsologest"] = $obj->ref;
|
||||
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->description;
|
||||
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
|
||||
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
|
||||
//$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
|
||||
|
||||
// Avoid warnings
|
||||
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
|
||||
if (! empty($line->tva_npr)) // Add an entry for counterpart
|
||||
if (!empty($line->tva_npr)) // Add an entry for counterpart
|
||||
{
|
||||
$tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
|
||||
}
|
||||
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
|
||||
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
$tabcompany[$obj->rowid] = array(
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_fournisseur' => $obj->code_fournisseur,
|
||||
@ -215,16 +215,16 @@ $errorforinvoice = array();
|
||||
// Loop in invoices to detect lines with not binding lines
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql.= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
|
||||
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->nb > 0)
|
||||
{
|
||||
$errorforinvoice[$key]='somelinesarenotbound';
|
||||
$errorforinvoice[$key] = 'somelinesarenotbound';
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
@ -271,7 +271,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Thirdparty
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
@ -473,7 +473,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->date_creation = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
||||
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
@ -497,14 +497,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
$errorforinvoice[$key] = 'alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
$errorforinvoice[$key] = 'other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -513,15 +513,15 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Protection against a bug on lines before
|
||||
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='amountsnotbalanced';
|
||||
$errorforinvoice[$key] = 'amountsnotbalanced';
|
||||
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
|
||||
}
|
||||
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
@ -532,7 +532,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -551,20 +551,20 @@ if ($action == 'writebookkeeping') {
|
||||
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||
}
|
||||
|
||||
$action='';
|
||||
$action = '';
|
||||
|
||||
// Must reload data, so we make a redirect
|
||||
if (count($tabpay) != $error)
|
||||
{
|
||||
$param='id_journal='.$id_journal;
|
||||
$param.='&date_startday='.$date_startday;
|
||||
$param.='&date_startmonth='.$date_startmonth;
|
||||
$param.='&date_startyear='.$date_startyear;
|
||||
$param.='&date_endday='.$date_endday;
|
||||
$param.='&date_endmonth='.$date_endmonth;
|
||||
$param.='&date_endyear='.$date_endyear;
|
||||
$param.='&in_bookkeeping='.$in_bookkeeping;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
|
||||
$param = 'id_journal='.$id_journal;
|
||||
$param .= '&date_startday='.$date_startday;
|
||||
$param .= '&date_startmonth='.$date_startmonth;
|
||||
$param .= '&date_startyear='.$date_startyear;
|
||||
$param .= '&date_endday='.$date_endday;
|
||||
$param .= '&date_endmonth='.$date_endmonth;
|
||||
$param .= '&date_endyear='.$date_endyear;
|
||||
$param .= '&in_bookkeeping='.$in_bookkeeping;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -581,7 +581,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
$filename = 'journal';
|
||||
$type_export = 'journal';
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
$companystatic = new Fournisseur($db);
|
||||
$invoicestatic = new FactureFournisseur($db);
|
||||
@ -610,7 +610,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -623,18 +623,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["refsologest"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.$langs->trans("Thirdparty").'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
@ -644,18 +644,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["refsologest"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '""'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
@ -669,18 +669,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["refsologest"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '""'.$sep;
|
||||
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -690,18 +690,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
{
|
||||
foreach ($tabother[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["refsologest"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.$langs->trans("Thirdparty").'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -713,23 +713,23 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
if (empty($action) || $action == 'view') {
|
||||
llxHeader('', $langs->trans("PurchasesJournal"));
|
||||
|
||||
$nom = $langs->trans("PurchasesJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nom = $langs->trans("PurchasesJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate=dol_now();
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$builddate = dol_now();
|
||||
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||
|
||||
@ -740,13 +740,13 @@ if (empty($action) || $action == 'view') {
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
|
||||
if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
|
||||
}
|
||||
else {
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@ -775,13 +775,13 @@ if (empty($action) || $action == 'view') {
|
||||
print '<div class="div-table-responsive">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print '<td class="center">' . $langs->trans("Debit") . "</td>";
|
||||
print '<td class="center">' . $langs->trans("Credit") . "</td>";
|
||||
print "<td>".$langs->trans("Date")."</td>";
|
||||
print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
|
||||
print "<td>".$langs->trans("AccountAccounting")."</td>";
|
||||
print "<td>".$langs->trans("SubledgerAccount")."</td>";
|
||||
print "<td>".$langs->trans("LabelOperation")."</td>";
|
||||
print '<td class="center">'.$langs->trans("Debit")."</td>";
|
||||
print '<td class="center">'.$langs->trans("Credit")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$r = '';
|
||||
@ -813,7 +813,7 @@ if (empty($action) || $action == 'view') {
|
||||
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -822,8 +822,8 @@ if (empty($action) || $action == 'view') {
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Replaced invoice -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td><strike>".$invoicestatic->getNomUrl(1)."</strike></td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
print $langs->trans("Replaced");
|
||||
@ -843,8 +843,8 @@ if (empty($action) || $action == 'view') {
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Some lines are not bound -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
|
||||
@ -929,8 +929,8 @@ if (empty($action) || $action == 'view') {
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- VAT -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accountg($k);
|
||||
@ -944,10 +944,10 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>";
|
||||
print $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print $companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
|
||||
print "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
|
||||
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
@ -960,8 +960,8 @@ if (empty($action) || $action == 'view') {
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- VAT counterpart NPR -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accountg($k);
|
||||
@ -974,9 +974,9 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT") . " NPR (counterpart)</td>";
|
||||
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT")." NPR (counterpart)</td>";
|
||||
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
|
||||
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,17 +31,17 @@
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
|
||||
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors"));
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -62,13 +62,13 @@ if ($user->socid > 0)
|
||||
accessforbidden();
|
||||
|
||||
$hookmanager->initHooks(array('sellsjournal'));
|
||||
$parameters=array();
|
||||
$parameters = array();
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
|
||||
@ -83,13 +83,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
$pastmonthyear--;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
|
||||
{
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
@ -132,45 +132,45 @@ $sql .= " ORDER BY f.datef";
|
||||
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$def_tva = array ();
|
||||
$tabttc = array ();
|
||||
$tablocaltax1 = array ();
|
||||
$tablocaltax2 = array ();
|
||||
$tabcompany = array ();
|
||||
$tabfac = array();
|
||||
$tabht = array();
|
||||
$tabtva = array();
|
||||
$def_tva = array();
|
||||
$tabttc = array();
|
||||
$tablocaltax1 = array();
|
||||
$tablocaltax2 = array();
|
||||
$tabcompany = array();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
// Variables
|
||||
$cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
|
||||
$cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
|
||||
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// Controls
|
||||
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||
$compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
|
||||
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
|
||||
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
|
||||
}
|
||||
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
|
||||
{
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
|
||||
}
|
||||
|
||||
$line = new FactureLigne($db);
|
||||
@ -196,29 +196,29 @@ if ($result) {
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->ref;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
|
||||
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
|
||||
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
|
||||
//$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
|
||||
|
||||
// Avoid warnings
|
||||
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
|
||||
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
|
||||
if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
|
||||
if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
|
||||
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
|
||||
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
$tabcompany[$obj->rowid] = array(
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_client,
|
||||
'code_compta' => $compta_soc
|
||||
);
|
||||
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -229,16 +229,16 @@ $errorforinvoice = array();
|
||||
// Loop in invoices to detect lines with not binding lines
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
$sql = "SELECT COUNT(fd.rowid) as nb";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql.= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
|
||||
$sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->nb > 0)
|
||||
{
|
||||
$errorforinvoice[$key]='somelinesarenotbound';
|
||||
$errorforinvoice[$key] = 'somelinesarenotbound';
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
@ -282,7 +282,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Thirdparty
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
@ -367,7 +367,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->date_creation = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
||||
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
@ -392,14 +392,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
$errorforinvoice[$key] = 'alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
$errorforinvoice[$key] = 'other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -454,14 +454,14 @@ if ($action == 'writebookkeeping') {
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='alreadyjournalized';
|
||||
$errorforinvoice[$key] = 'alreadyjournalized';
|
||||
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='other';
|
||||
$errorforinvoice[$key] = 'other';
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -471,15 +471,15 @@ if ($action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Protection against a bug on lines before
|
||||
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit)))
|
||||
{
|
||||
$error++;
|
||||
$errorforline++;
|
||||
$errorforinvoice[$key]='amountsnotbalanced';
|
||||
$errorforinvoice[$key] = 'amountsnotbalanced';
|
||||
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
|
||||
}
|
||||
|
||||
if (! $errorforline)
|
||||
if (!$errorforline)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
@ -490,7 +490,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -509,20 +509,20 @@ if ($action == 'writebookkeeping') {
|
||||
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||
}
|
||||
|
||||
$action='';
|
||||
$action = '';
|
||||
|
||||
// Must reload data, so we make a redirect
|
||||
if (count($tabpay) != $error)
|
||||
{
|
||||
$param='id_journal='.$id_journal;
|
||||
$param.='&date_startday='.$date_startday;
|
||||
$param.='&date_startmonth='.$date_startmonth;
|
||||
$param.='&date_startyear='.$date_startyear;
|
||||
$param.='&date_endday='.$date_endday;
|
||||
$param.='&date_endmonth='.$date_endmonth;
|
||||
$param.='&date_endyear='.$date_endyear;
|
||||
$param.='&in_bookkeeping='.$in_bookkeeping;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
|
||||
$param = 'id_journal='.$id_journal;
|
||||
$param .= '&date_startday='.$date_startday;
|
||||
$param .= '&date_startmonth='.$date_startmonth;
|
||||
$param .= '&date_startyear='.$date_startyear;
|
||||
$param .= '&date_endday='.$date_endday;
|
||||
$param .= '&date_endmonth='.$date_endmonth;
|
||||
$param .= '&date_endyear='.$date_endyear;
|
||||
$param .= '&in_bookkeeping='.$in_bookkeeping;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -541,7 +541,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
$filename = 'journal';
|
||||
$type_export = 'journal';
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
$companystatic = new Client($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
@ -568,7 +568,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -581,18 +581,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.$langs->trans("Thirdparty").'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
@ -602,18 +602,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
//if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '""'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
//}
|
||||
}
|
||||
@ -627,18 +627,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '""'.$sep;
|
||||
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.$journal.'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -651,22 +651,22 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
if (empty($action) || $action == 'view') {
|
||||
llxHeader('', $langs->trans("SellsJournal"));
|
||||
|
||||
$nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nom = $langs->trans("SellsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate=dol_now();
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$builddate = dol_now();
|
||||
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
else
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||
|
||||
@ -677,13 +677,13 @@ if (empty($action) || $action == 'view') {
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
|
||||
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
|
||||
}
|
||||
else {
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
|
||||
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
|
||||
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@ -712,13 +712,13 @@ if (empty($action) || $action == 'view') {
|
||||
print '<div class="div-table-responsive">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>" . $langs->trans("Date") . "</td>";
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print '<td class="center">' . $langs->trans("Debit") . "</td>";
|
||||
print '<td class="center">' . $langs->trans("Credit") . "</td>";
|
||||
print "<td>".$langs->trans("Date")."</td>";
|
||||
print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
|
||||
print "<td>".$langs->trans("AccountAccounting")."</td>";
|
||||
print "<td>".$langs->trans("SubledgerAccount")."</td>";
|
||||
print "<td>".$langs->trans("LabelOperation")."</td>";
|
||||
print '<td class="center">'.$langs->trans("Debit")."</td>";
|
||||
print '<td class="center">'.$langs->trans("Credit")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$r = '';
|
||||
@ -748,7 +748,7 @@ if (empty($action) || $action == 'view') {
|
||||
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
|
||||
{
|
||||
$replacedinvoice = 1;
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
|
||||
if ($alreadydispatched) $replacedinvoice = 2;
|
||||
}
|
||||
|
||||
@ -757,8 +757,8 @@ if (empty($action) || $action == 'view') {
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Replaced invoice -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td><strike>".$invoicestatic->getNomUrl(1)."</strike></td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
print $langs->trans("Replaced");
|
||||
@ -778,8 +778,8 @@ if (empty($action) || $action == 'view') {
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- Some lines are not bound -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
|
||||
@ -867,8 +867,8 @@ if (empty($action) || $action == 'view') {
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
print "<!-- VAT -->";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
print "<td>".$date."</td>";
|
||||
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
||||
// Account
|
||||
print "<td>";
|
||||
$accountoshow = length_accountg($k);
|
||||
@ -881,10 +881,10 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
|
||||
print "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
|
||||
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || ! is_object($conf))
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
@ -32,8 +32,8 @@ $langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
$langs->load("members");
|
||||
|
||||
$total=0;
|
||||
foreach($linkedObjectBlock as $key => $objectlink)
|
||||
$total = 0;
|
||||
foreach ($linkedObjectBlock as $key => $objectlink)
|
||||
{
|
||||
echo '<tr class="oddeven">';
|
||||
echo '<td>'.$langs->trans("Subscription").'</td>';
|
||||
|
||||
@ -53,8 +53,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
||||
$code = $reg[1];
|
||||
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
|
||||
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
@ -68,7 +68,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
$code = $reg[1];
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
||||
{
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
@ -88,21 +88,21 @@ if ($action == 'set')
|
||||
}
|
||||
elseif ($action == 'specimen') // For orders
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty=$specimenthirdparty;
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -171,18 +171,18 @@ elseif ($action == 'setdoc')
|
||||
* View
|
||||
*/
|
||||
|
||||
$formactions=new FormActions($db);
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$formactions = new FormActions($db);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
|
||||
|
||||
|
||||
|
||||
$head=agenda_prepare_head();
|
||||
$head = agenda_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
|
||||
|
||||
@ -196,15 +196,15 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
|
||||
$def = array();
|
||||
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = 'action'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = 'action'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -239,22 +239,22 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new ActionComm($db));
|
||||
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
@ -301,11 +301,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
@ -353,15 +353,15 @@ print '</td></tr>'."\n";
|
||||
|
||||
// AGENDA_DEFAULT_VIEW
|
||||
print '<tr class="oddeven">'."\n";
|
||||
$htmltext=$langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
|
||||
$htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
|
||||
print '<td>'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
$tmplist=array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
|
||||
$tmplist = array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
|
||||
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
|
||||
print '<tr class="oddeven">'."\n";
|
||||
|
||||
@ -45,15 +45,15 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
if ($action == 'setbarcodeproducton')
|
||||
{
|
||||
$barcodenumberingmodule = GETPOST('value', 'alpha');
|
||||
$res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
|
||||
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
|
||||
{
|
||||
$res=dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
}
|
||||
elseif ($action == 'setbarcodeproductoff')
|
||||
{
|
||||
$res=dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
||||
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
||||
}
|
||||
|
||||
if ($action == 'setcoder')
|
||||
@ -61,12 +61,12 @@ if ($action == 'setcoder')
|
||||
$coder = GETPOST('coder', 'alpha');
|
||||
$code_id = GETPOST('code_id', 'alpha');
|
||||
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
||||
$sqlp.= " SET coder = '" . $coder."'";
|
||||
$sqlp.= " WHERE rowid = ". $code_id;
|
||||
$sqlp.= " AND entity = ".$conf->entity;
|
||||
$sqlp .= " SET coder = '".$coder."'";
|
||||
$sqlp .= " WHERE rowid = ".$code_id;
|
||||
$sqlp .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sqlp);
|
||||
if (! $resql) dol_print_error($db);
|
||||
$resql = $db->query($sqlp);
|
||||
if (!$resql) dol_print_error($db);
|
||||
}
|
||||
elseif ($action == 'update')
|
||||
{
|
||||
@ -130,33 +130,33 @@ elseif ($action == 'updateengine')
|
||||
$form = new Form($db);
|
||||
$formbarcode = new FormBarCode($db);
|
||||
|
||||
$help_url='EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra';
|
||||
$help_url = 'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra';
|
||||
llxHeader('', $langs->trans("BarcodeSetup"), $help_url);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("BarcodeSetup"), $linkback, 'title_setup');
|
||||
|
||||
// Detect bar codes modules
|
||||
$barcodelist=array();
|
||||
$barcodelist = array();
|
||||
|
||||
clearstatcache();
|
||||
|
||||
|
||||
// Scan list of all barcode included provided by external modules
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
||||
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
foreach ($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir);
|
||||
$newdir=dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
if (!is_dir($newdir)) continue;
|
||||
|
||||
$handle=@opendir($newdir);
|
||||
$handle = @opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
@ -164,7 +164,7 @@ foreach($dirbarcode as $reldir)
|
||||
{
|
||||
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg))
|
||||
{
|
||||
$filebis=$reg[1];
|
||||
$filebis = $reg[1];
|
||||
|
||||
// Loading encoding class
|
||||
require_once $newdir.$file;
|
||||
@ -172,12 +172,12 @@ foreach($dirbarcode as $reldir)
|
||||
$module = new $classname($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
$barcodelist[$filebis]=$module->info();
|
||||
$barcodelist[$filebis] = $module->info();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,17 +237,17 @@ if ($resql)
|
||||
print '<td class="center">';
|
||||
if ($obj->coder && $obj->coder != -1)
|
||||
{
|
||||
$result=0;
|
||||
$result = 0;
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
foreach ($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir, 0);
|
||||
$newdir=dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
if (!is_dir($newdir)) continue;
|
||||
|
||||
$result=@include_once $newdir.$obj->coder.'.modules.php';
|
||||
$result = @include_once $newdir.$obj->coder.'.modules.php';
|
||||
if ($result) break;
|
||||
}
|
||||
if ($result)
|
||||
@ -259,9 +259,9 @@ if ($resql)
|
||||
if ($module->encodingIsSupported($obj->encoding))
|
||||
{
|
||||
// Build barcode on disk (not used, this is done to make debug easier)
|
||||
$result=$module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
||||
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
||||
// Generate on the fly and output barcode with generator
|
||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding);
|
||||
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding);
|
||||
//print $url;
|
||||
print '<img src="'.$url.'" title="'.$obj->example.'" border="0">';
|
||||
}
|
||||
@ -317,13 +317,13 @@ print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Chemin du binaire genbarcode sous linux
|
||||
if (! isset($_SERVER['WINDIR']))
|
||||
if (!isset($_SERVER['WINDIR']))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
|
||||
print '<td width="60" class="center">';
|
||||
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
|
||||
if (! empty($conf->global->GENBARCODE_LOCATION) && ! @file_exists($conf->global->GENBARCODE_LOCATION))
|
||||
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
|
||||
@ -332,7 +332,7 @@ if (! isset($_SERVER['WINDIR']))
|
||||
}
|
||||
|
||||
// Module products
|
||||
if (! empty($conf->product->enabled))
|
||||
if (!empty($conf->product->enabled))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
|
||||
@ -342,7 +342,7 @@ if (! empty($conf->product->enabled))
|
||||
}
|
||||
|
||||
// Module thirdparty
|
||||
if (! empty($conf->societe->enabled))
|
||||
if (!empty($conf->societe->enabled))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
|
||||
@ -375,7 +375,7 @@ if ($conf->product->enabled)
|
||||
print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$dirbarcodenum=array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
||||
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
||||
|
||||
foreach ($dirbarcodenum as $dirroot)
|
||||
{
|
||||
@ -384,16 +384,16 @@ if ($conf->product->enabled)
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/^mod_barcode_product_.*php$/', $file))
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
try {
|
||||
dol_include_once($dirroot.$file.'.php');
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
@ -401,7 +401,7 @@ if ($conf->product->enabled)
|
||||
$modBarCode = new $file();
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.(isset($modBarCode->name)?$modBarCode->name:$modBarCode->nom)."</td><td>\n";
|
||||
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
|
||||
print $modBarCode->info($langs);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||
@ -419,7 +419,7 @@ if ($conf->product->enabled)
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td class="center">';
|
||||
$s=$modBarCode->getToolTip($langs, null, -1);
|
||||
$s = $modBarCode->getToolTip($langs, null, -1);
|
||||
print $form->textwithpicto('', $s, 1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
@ -56,14 +56,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstorder=GETPOST('maskconstorder', 'alpha');
|
||||
$maskorder=GETPOST('maskorder', 'alpha');
|
||||
$maskconstorder = GETPOST('maskconstorder', 'alpha');
|
||||
$maskorder = GETPOST('maskorder', 'alpha');
|
||||
|
||||
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -75,20 +75,20 @@ if ($action == 'updateMask')
|
||||
|
||||
elseif ($action == 'specimen')
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -164,9 +164,9 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK')
|
||||
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
|
||||
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -178,13 +178,13 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK')
|
||||
|
||||
elseif ($action == 'set_ORDER_FREE_TEXT')
|
||||
{
|
||||
$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
|
||||
|
||||
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -192,12 +192,12 @@ elseif ($action == 'set_ORDER_FREE_TEXT')
|
||||
{
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action=="setshippableiconinlist") {
|
||||
} elseif ($action == "setshippableiconinlist") {
|
||||
// Activate Set Shippable Icon In List
|
||||
$setshippableiconinlist = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
if (! $error) {
|
||||
if (!$res > 0) $error++;
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -209,9 +209,9 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
|
||||
{
|
||||
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -226,9 +226,9 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
|
||||
{
|
||||
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -243,13 +243,13 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
|
||||
* View
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader("", $langs->trans("OrdersSetup"));
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
|
||||
|
||||
$head = order_admin_prepare_head();
|
||||
@ -282,18 +282,18 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
$module = new $file($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
@ -304,9 +304,9 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -323,22 +323,22 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$commande=new Commande($db);
|
||||
$commande = new Commande($db);
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$commande->type=0;
|
||||
$nextval=$module->getNextValue($mysoc, $commande);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$commande->type = 0;
|
||||
$nextval = $module->getNextValue($mysoc, $commande);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,14 +366,14 @@ print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
|
||||
// Load array def with activated templates
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -401,42 +401,42 @@ clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('','/doc') as $valdir)
|
||||
foreach (array('', '/doc') as $valdir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/commande".$valdir);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
@ -528,18 +528,18 @@ print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='ORDER_FREE_TEXT';
|
||||
$variablename = 'ORDER_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -547,7 +547,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
|
||||
@ -37,52 +37,52 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
|
||||
$action=GETPOST('action', 'aZ09');
|
||||
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'admincompany'; // To manage different context of search
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'companies'));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('admincompany','globaladmin'));
|
||||
$hookmanager->initHooks(array('admincompany', 'globaladmin'));
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
|| ($action == 'updateedit') )
|
||||
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|
||||
|| ($action == 'updateedit'))
|
||||
{
|
||||
$tmparray=getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
|
||||
if (! empty($tmparray['id']))
|
||||
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
|
||||
if (!empty($tmparray['id']))
|
||||
{
|
||||
$mysoc->country_id =$tmparray['id'];
|
||||
$mysoc->country_code =$tmparray['code'];
|
||||
$mysoc->country_label=$tmparray['label'];
|
||||
$mysoc->country_id = $tmparray['id'];
|
||||
$mysoc->country_code = $tmparray['code'];
|
||||
$mysoc->country_label = $tmparray['label'];
|
||||
|
||||
$s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
|
||||
$s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
activateModulesRequiredByCountry($mysoc->country_code);
|
||||
}
|
||||
|
||||
$tmparray=getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
|
||||
if (! empty($tmparray['id']))
|
||||
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
|
||||
if (!empty($tmparray['id']))
|
||||
{
|
||||
$mysoc->state_id =$tmparray['id'];
|
||||
$mysoc->state_code =$tmparray['code'];
|
||||
$mysoc->state_label=$tmparray['label'];
|
||||
$mysoc->state_id = $tmparray['id'];
|
||||
$mysoc->state_code = $tmparray['code'];
|
||||
$mysoc->state_label = $tmparray['label'];
|
||||
|
||||
$s=$mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
|
||||
$s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
else
|
||||
@ -105,28 +105,28 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
$dirforimage=$conf->mycompany->dir_output.'/logos/';
|
||||
$dirforimage = $conf->mycompany->dir_output.'/logos/';
|
||||
|
||||
$arrayofimages = array('logo', 'logo_squarred');
|
||||
|
||||
foreach($arrayofimages as $varforimage)
|
||||
foreach ($arrayofimages as $varforimage)
|
||||
{
|
||||
if ($_FILES[$varforimage]["tmp_name"])
|
||||
{
|
||||
$reg = array();
|
||||
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg))
|
||||
{
|
||||
$original_file=$reg[1];
|
||||
$original_file = $reg[1];
|
||||
|
||||
$isimage=image_format_supported($original_file);
|
||||
$isimage = image_format_supported($original_file);
|
||||
if ($isimage >= 0)
|
||||
{
|
||||
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
|
||||
if (! is_dir($dirforimage))
|
||||
if (!is_dir($dirforimage))
|
||||
{
|
||||
dol_mkdir($dirforimage);
|
||||
}
|
||||
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
|
||||
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
|
||||
if ($result > 0)
|
||||
{
|
||||
$constant = "MAIN_INFO_SOCIETE_LOGO";
|
||||
@ -144,7 +144,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
|
||||
{
|
||||
$imgThumbSmall = $reg[1]; // Save only basename
|
||||
$imgThumbSmall = $reg[1]; // Save only basename
|
||||
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
else dol_syslog($imgThumbSmall);
|
||||
@ -153,7 +153,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
|
||||
{
|
||||
$imgThumbMini = $reg[1]; // Save only basename
|
||||
$imgThumbMini = $reg[1]; // Save only basename
|
||||
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
else dol_syslog($imgThumbMini);
|
||||
@ -162,7 +162,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$tmparray=explode(':', $result);
|
||||
$tmparray = explode(':', $result);
|
||||
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
|
||||
}
|
||||
else
|
||||
@ -201,12 +201,12 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
$usevat = GETPOST("optiontva", 'aZ09');
|
||||
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
|
||||
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
|
||||
if ($uselocaltax1 == 'localtax1on' && ! $usevat)
|
||||
if ($uselocaltax1 == 'localtax1on' && !$usevat)
|
||||
{
|
||||
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($uselocaltax2 == 'localtax2on' && ! $usevat)
|
||||
if ($uselocaltax2 == 'localtax2on' && !$usevat)
|
||||
{
|
||||
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
|
||||
$error++;
|
||||
@ -216,9 +216,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if($_POST["optionlocaltax1"]=="localtax1on")
|
||||
if ($_POST["optionlocaltax1"] == "localtax1on")
|
||||
{
|
||||
if(!isset($_REQUEST['lt1']))
|
||||
if (!isset($_REQUEST['lt1']))
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
@ -228,9 +228,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
}
|
||||
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if($_POST["optionlocaltax2"]=="localtax2on")
|
||||
if ($_POST["optionlocaltax2"] == "localtax2on")
|
||||
{
|
||||
if(!isset($_REQUEST['lt2']))
|
||||
if (!isset($_REQUEST['lt2']))
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
@ -241,7 +241,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
@ -250,7 +250,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
if ($action != 'updateedit' && ! $error)
|
||||
if ($action != 'updateedit' && !$error)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
@ -261,7 +261,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
|
||||
{
|
||||
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
|
||||
{
|
||||
$isimage=image_format_supported($_GET["file"]);
|
||||
$isimage = image_format_supported($_GET["file"]);
|
||||
|
||||
// Create thumbs of logo
|
||||
if ($isimage > 0)
|
||||
@ -278,7 +278,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
|
||||
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
|
||||
{
|
||||
$imgThumbSmall = $reg[1]; // Save only basename
|
||||
$imgThumbSmall = $reg[1]; // Save only basename
|
||||
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
else dol_syslog($imgThumbSmall);
|
||||
@ -287,7 +287,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
|
||||
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
|
||||
{
|
||||
$imgThumbMini = $reg[1]; // Save only basename
|
||||
$imgThumbMini = $reg[1]; // Save only basename
|
||||
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
else dol_syslog($imgThumbMini);
|
||||
@ -328,11 +328,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
|
||||
$logofilenamebis = $mysoc->logo;
|
||||
}
|
||||
|
||||
$logofile=$conf->mycompany->dir_output.'/logos/'.$logofilename;
|
||||
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
|
||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile);
|
||||
dolibarr_del_const($db, $constant, $conf->entity);
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred='';
|
||||
else $mysoc->logo='';
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred = '';
|
||||
else $mysoc->logo = '';
|
||||
|
||||
$logofilename = $mysoc->logo_small;
|
||||
$logofilenamebis = $mysoc->logo_squarred_small;
|
||||
@ -342,11 +342,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
|
||||
$logofilenamebis = $mysoc->logo_small;
|
||||
}
|
||||
|
||||
$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile);
|
||||
dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small='';
|
||||
else $mysoc->logo_small='';
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = '';
|
||||
else $mysoc->logo_small = '';
|
||||
|
||||
$logofilename = $mysoc->logo_mini;
|
||||
$logofilenamebis = $mysoc->logo_squarred_mini;
|
||||
@ -356,11 +356,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
|
||||
$logofilenamebis = $mysoc->logo_mini;
|
||||
}
|
||||
|
||||
$logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
|
||||
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile);
|
||||
dolibarr_del_const($db, $constant."_MINI", $conf->entity);
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini='';
|
||||
else $mysoc->logo_mini='';
|
||||
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = '';
|
||||
else $mysoc->logo_mini = '';
|
||||
}
|
||||
|
||||
|
||||
@ -368,14 +368,14 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
|
||||
* View
|
||||
*/
|
||||
|
||||
$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
||||
$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
||||
llxHeader('', $langs->trans("Setup"), $wikihelp);
|
||||
|
||||
$form=new Form($db);
|
||||
$formother=new FormOther($db);
|
||||
$formcompany=new FormCompany($db);
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
|
||||
$countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
|
||||
|
||||
print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
|
||||
|
||||
@ -434,11 +434,11 @@ print '</td></tr>'."\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
|
||||
$state_id=0;
|
||||
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE))
|
||||
$state_id = 0;
|
||||
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE))
|
||||
{
|
||||
$tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
|
||||
$state_id=$tmp[0];
|
||||
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
|
||||
$state_id = $tmp[0];
|
||||
}
|
||||
$formcompany->select_departement($state_id, $mysoc->country_code, 'state_id');
|
||||
print '</td></tr>'."\n";
|
||||
@ -450,28 +450,28 @@ print '</td></tr>'."\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
|
||||
print '<input name="tel" id="phone" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL) . '"></td></tr>';
|
||||
print '<input name="tel" id="phone" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'"></td></tr>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
|
||||
print '<input name="fax" id="fax" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FAX) . '"></td></tr>';
|
||||
print '<input name="fax" id="fax" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FAX).'"></td></tr>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
|
||||
print '<input name="mail" id="email" class="minwidth200" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL) . '"></td></tr>';
|
||||
print '<input name="mail" id="email" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'"></td></tr>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Web
|
||||
print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
|
||||
print '<input name="web" id="web" class="minwidth300" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB) . '"></td></tr>';
|
||||
print '<input name="web" id="web" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'"></td></tr>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Barcode
|
||||
if (! empty($conf->barcode->enabled)) {
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
print '<tr class="oddeven"><td><label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
|
||||
print '<input name="barcode" id="barcode" class="minwidth150" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_GENCOD) . '"></td></tr>';
|
||||
print '<input name="barcode" id="barcode" class="minwidth150" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_GENCOD).'"></td></tr>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->
|
||||
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
|
||||
print '<input type="file" class="flat minwidth200" name="logo" id="logo" accept="image/*">';
|
||||
print '</td><td class="nocellnopadd right" valign="middle">';
|
||||
if (! empty($mysoc->logo_mini)) {
|
||||
if (!empty($mysoc->logo_mini)) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
|
||||
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
|
||||
print ' ';
|
||||
@ -497,7 +497,7 @@ print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto
|
||||
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
|
||||
print '<input type="file" class="flat minwidth200" name="logo_squarred" id="logo_squarred" accept="image/*">';
|
||||
print '</td><td class="nocellnopadd right" valign="middle">';
|
||||
if (! empty($mysoc->logo_squarred_mini)) {
|
||||
if (!empty($mysoc->logo_squarred_mini)) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete")).'</a>';
|
||||
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
|
||||
print ' ';
|
||||
@ -527,19 +527,19 @@ $langs->load("companies");
|
||||
// Managing Director(s)
|
||||
|
||||
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
|
||||
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS) . '"></td></tr>';
|
||||
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS).'"></td></tr>';
|
||||
|
||||
// GDPR contact
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
|
||||
print '</td><td>';
|
||||
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_GDPR) . '"></td></tr>';
|
||||
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_GDPR).'"></td></tr>';
|
||||
|
||||
// Capital
|
||||
|
||||
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
|
||||
print '<input name="capital" id="capital" class="minwidth100" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_CAPITAL) . '"></td></tr>';
|
||||
print '<input name="capital" id="capital" class="minwidth100" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_CAPITAL).'"></td></tr>';
|
||||
|
||||
// Juridical Status
|
||||
|
||||
@ -555,9 +555,9 @@ print '</td></tr>';
|
||||
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="siren" id="profid1" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">';
|
||||
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -570,9 +570,9 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
|
||||
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="siret" id="profid2" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '') . '">';
|
||||
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -585,9 +585,9 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
|
||||
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="ape" id="profid3" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">';
|
||||
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -600,9 +600,9 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
|
||||
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="rcs" id="profid4" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">';
|
||||
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -615,9 +615,9 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
|
||||
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">';
|
||||
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -630,9 +630,9 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
|
||||
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
|
||||
{
|
||||
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
|
||||
if (! empty($mysoc->country_code))
|
||||
if (!empty($mysoc->country_code))
|
||||
{
|
||||
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">';
|
||||
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -644,13 +644,13 @@ if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
|
||||
// TVA Intra
|
||||
|
||||
print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
|
||||
print '<input name="tva" id="intra_vat" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
|
||||
print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Object of the company
|
||||
|
||||
print '<tr class="oddeven"><td><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
|
||||
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
|
||||
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(!empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
@ -664,7 +664,7 @@ print '<td class="titlefield">'.$langs->trans("FiscalYearInformation").'</td><td
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
|
||||
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100') . '</td></tr>';
|
||||
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -678,7 +678,7 @@ print '<td class="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
|
||||
print '<td colspan="2">';
|
||||
print "<table>";
|
||||
print "<tr><td><label for=\"use_vat\">".$langs->trans("VATIsUsedDesc")."</label></td></tr>";
|
||||
@ -687,7 +687,7 @@ print "</table>";
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"no_vat\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"no_vat\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
|
||||
print '<td colspan="2">';
|
||||
print "<table>";
|
||||
print "<tr><td><label for=\"no_vat\">".$langs->trans("VATIsNotUsedDesc")."</label></td></tr>";
|
||||
@ -711,20 +711,20 @@ if ($mysoc->useLocalTax(1))
|
||||
print "</tr>\n";
|
||||
|
||||
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<table class="nobordernopadding">';
|
||||
print "<tr><td><label for=\"lt1\">".$langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)."</label></td></tr>";
|
||||
$example=$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
|
||||
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
|
||||
if(! isOnlyOneLocalTax(1))
|
||||
$example = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
|
||||
print ($example != "LocalTax1IsUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
|
||||
if (!isOnlyOneLocalTax(1))
|
||||
{
|
||||
print '<tr><td class="left"><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
|
||||
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
$opcions=array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"),$langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"),$langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
|
||||
$opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
|
||||
|
||||
print '<tr><td class="left"></label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
|
||||
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
|
||||
@ -733,12 +733,12 @@ if ($mysoc->useLocalTax(1))
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" value=\"localtax1off\"".((empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."</td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" value=\"localtax1off\"".((empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."</td>";
|
||||
print '<td colspan="2">';
|
||||
print "<table>";
|
||||
print "<tr><td><label for=\"nolt1\">".$langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code)."</label></td></tr>";
|
||||
$example=$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
|
||||
print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
|
||||
$example = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
|
||||
print ($example != "LocalTax1IsNotUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
|
||||
print "</table>";
|
||||
print "</td></tr>\n";
|
||||
print "</table>";
|
||||
@ -755,13 +755,13 @@ if ($mysoc->useLocalTax(2))
|
||||
|
||||
|
||||
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<table class="nobordernopadding">';
|
||||
print "<tr><td><label for=\"lt2\">".$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label></td></tr>";
|
||||
$example=$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
|
||||
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
|
||||
if(! isOnlyOneLocalTax(2))
|
||||
$example = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
|
||||
print ($example != "LocalTax2IsUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
|
||||
if (!isOnlyOneLocalTax(2))
|
||||
{
|
||||
print '<tr><td class="left"><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
|
||||
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
|
||||
@ -774,12 +774,12 @@ if ($mysoc->useLocalTax(2))
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"".((empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."</td>";
|
||||
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"".((empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."</td>";
|
||||
print '<td colspan="2">';
|
||||
print "<table>";
|
||||
print "<tr><td><label for=\"nolt2\">".$langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code)."</label></td></tr>";
|
||||
$example=$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
|
||||
print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
|
||||
$example = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
|
||||
print ($example != "LocalTax2IsNotUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
|
||||
print "</table>";
|
||||
print "</td></tr>\n";
|
||||
print "</table>";
|
||||
|
||||
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin","errors","contracts"));
|
||||
$langs->loadLangs(array("admin", "errors", "contracts"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
@ -37,11 +37,11 @@ $action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type='contract';
|
||||
$type = 'contract';
|
||||
|
||||
if (empty($conf->global->CONTRACT_ADDON))
|
||||
{
|
||||
$conf->global->CONTRACT_ADDON='mod_contract_serpis';
|
||||
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
|
||||
}
|
||||
|
||||
|
||||
@ -54,12 +54,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconst = GETPOST('maskconstcontract', 'alpha');
|
||||
$maskvalue = GETPOST('maskcontract', 'alpha');
|
||||
$maskvalue = GETPOST('maskcontract', 'alpha');
|
||||
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -71,20 +71,20 @@ if ($action == 'updateMask')
|
||||
|
||||
elseif ($action == 'specimen') // For contract
|
||||
{
|
||||
$modele= GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$contract = new Contrat($db);
|
||||
$contract->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -157,15 +157,15 @@ elseif ($action == 'setmod')
|
||||
|
||||
elseif ($action == 'set_other')
|
||||
{
|
||||
$freetext= GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
$draft= GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
|
||||
$draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
|
||||
$res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res1 > 0 || ! $res2 > 0) $error++;
|
||||
if (!$res1 > 0 || !$res2 > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -180,16 +180,16 @@ elseif ($action == 'set_other')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("ContractsSetup"), $linkback, 'title_setup');
|
||||
|
||||
$head=contract_admin_prepare_head();
|
||||
$head = contract_admin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'contract', $langs->trans("Contracts"), -1, 'contract');
|
||||
|
||||
@ -219,18 +219,18 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
$module = new $file($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
@ -241,9 +241,9 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -260,21 +260,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$contract=new Contrat($db);
|
||||
$contract = new Contrat($db);
|
||||
$contract->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $contract);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $contract);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,14 +302,14 @@ print load_fiche_titre($langs->trans("TemplatePDFContracts"), '', '');
|
||||
// Defini tableau def des modeles
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -337,42 +337,42 @@ clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('','/doc') as $valdir)
|
||||
foreach (array('', '/doc') as $valdir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/contract".$valdir);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
@ -466,16 +466,16 @@ print '<td>'.$langs->trans("Parameter").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
|
||||
print '<br>';
|
||||
$variablename='CONTRACT_FREE_TEXT';
|
||||
$variablename = 'CONTRACT_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -483,7 +483,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
@ -37,13 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'errors', 'interventions', 'other'));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type='ficheinter';
|
||||
$type = 'ficheinter';
|
||||
|
||||
|
||||
/*
|
||||
@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconst=GETPOST('maskconst', 'alpha');
|
||||
$maskvalue=GETPOST('maskvalue', 'alpha');
|
||||
$maskconst = GETPOST('maskconst', 'alpha');
|
||||
$maskvalue = GETPOST('maskvalue', 'alpha');
|
||||
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -72,20 +72,20 @@ if ($action == 'updateMask')
|
||||
|
||||
elseif ($action == 'specimen') // For fiche inter
|
||||
{
|
||||
$modele= GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$inter = new Fichinter($db);
|
||||
$inter->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -158,12 +158,12 @@ elseif ($action == 'setmod')
|
||||
|
||||
elseif ($action == 'set_FICHINTER_FREE_TEXT')
|
||||
{
|
||||
$freetext= GETPOST('FICHINTER_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST('FICHINTER_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -175,12 +175,12 @@ elseif ($action == 'set_FICHINTER_FREE_TEXT')
|
||||
|
||||
elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK')
|
||||
{
|
||||
$draft= GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha');
|
||||
$draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha');
|
||||
$res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -195,9 +195,9 @@ elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS')
|
||||
$val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha');
|
||||
$res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -252,17 +252,17 @@ elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("InterventionsSetup"), $linkback, 'title_setup');
|
||||
|
||||
|
||||
$head=fichinter_admin_prepare_head();
|
||||
$head = fichinter_admin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), -1, 'intervention');
|
||||
|
||||
@ -290,7 +290,7 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/^(mod_.*)\.php$/i', $file, $reg))
|
||||
{
|
||||
@ -304,7 +304,7 @@ foreach ($dirmodels as $reldir)
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
|
||||
@ -314,9 +314,9 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -331,21 +331,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$ficheinter=new Fichinter($db);
|
||||
$ficheinter = new Fichinter($db);
|
||||
$ficheinter->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $ficheinter);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $ficheinter);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
print '<td align="center">';
|
||||
@ -371,17 +371,17 @@ print '</table><br>';
|
||||
print load_fiche_titre($langs->trans("TemplatePDFInterventions"), '', '');
|
||||
|
||||
// Defini tableau def des modeles
|
||||
$type='ficheinter';
|
||||
$type = 'ficheinter';
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -413,36 +413,36 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
@ -477,15 +477,15 @@ foreach ($dirmodels as $reldir)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, -1, 0);
|
||||
print '</td>';
|
||||
@ -526,18 +526,18 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_FICHINTER_FREE_TEXT">';
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='FICHINTER_FREE_TEXT';
|
||||
$variablename = 'FICHINTER_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -545,7 +545,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
@ -580,50 +580,50 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
|
||||
print "</td></tr>\n";
|
||||
print '</form>';
|
||||
// Use services duration
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_FICHINTER_USE_SERVICE_DURATION">';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $langs->trans("UseServicesDurationOnFichinter");
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="FICHINTER_USE_SERVICE_DURATION"' . ($conf->global->FICHINTER_USE_SERVICE_DURATION?' checked':'') . '>';
|
||||
print '<input type="checkbox" name="FICHINTER_USE_SERVICE_DURATION"'.($conf->global->FICHINTER_USE_SERVICE_DURATION ? ' checked' : '').'>';
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
// Use duration
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_FICHINTER_WITHOUT_DURATION">';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $langs->trans("UseDurationOnFichinter");
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="FICHINTER_WITHOUT_DURATION"' . ($conf->global->FICHINTER_WITHOUT_DURATION?' checked':'') . '>';
|
||||
print '<input type="checkbox" name="FICHINTER_WITHOUT_DURATION"'.($conf->global->FICHINTER_WITHOUT_DURATION ? ' checked' : '').'>';
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
// use date without hour
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_FICHINTER_DATE_WITHOUT_HOUR">';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $langs->trans("UseDateWithoutHourOnFichinter");
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="FICHINTER_DATE_WITHOUT_HOUR"' . ($conf->global->FICHINTER_DATE_WITHOUT_HOUR?' checked':'') . '>';
|
||||
print '<input type="checkbox" name="FICHINTER_DATE_WITHOUT_HOUR"'.($conf->global->FICHINTER_DATE_WITHOUT_HOUR ? ' checked' : '').'>';
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type='delivery';
|
||||
$type = 'delivery';
|
||||
|
||||
|
||||
/*
|
||||
@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstdelivery=GETPOST('maskconstdelivery', 'alpha');
|
||||
$maskdelivery=GETPOST('maskdelivery', 'alpha');
|
||||
$maskconstdelivery = GETPOST('maskconstdelivery', 'alpha');
|
||||
$maskdelivery = GETPOST('maskdelivery', 'alpha');
|
||||
if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -72,12 +72,12 @@ if ($action == 'updateMask')
|
||||
|
||||
if ($action == 'set_DELIVERY_FREE_TEXT')
|
||||
{
|
||||
$free=GETPOST('DELIVERY_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
|
||||
$free = GETPOST('DELIVERY_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -89,20 +89,20 @@ if ($action == 'set_DELIVERY_FREE_TEXT')
|
||||
|
||||
if ($action == 'specimen')
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$sending = new Livraison($db);
|
||||
$sending->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/livraison/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/livraison/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -176,13 +176,13 @@ if ($action == 'setmod')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader("", "");
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup');
|
||||
print '<br>';
|
||||
$head = expedition_admin_prepare_head();
|
||||
@ -214,11 +214,11 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
@ -227,7 +227,7 @@ foreach ($dirmodels as $reldir)
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
|
||||
@ -237,11 +237,11 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering module
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) {
|
||||
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
}
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -256,21 +256,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$livraison=new Livraison($db);
|
||||
$livraison = new Livraison($db);
|
||||
$livraison->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $livraison);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $livraison);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,19 +297,19 @@ print '<br>';
|
||||
print load_fiche_titre($langs->trans("DeliveryOrderModel"), '', '');
|
||||
|
||||
// Defini tableau def de modele
|
||||
$type="delivery";
|
||||
$type = "delivery";
|
||||
$def = array();
|
||||
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -343,33 +343,33 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
@ -404,10 +404,10 @@ foreach ($dirmodels as $reldir)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").'</u>:';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").'</u>:';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
@ -447,18 +447,18 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print '<td width="80"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='DELIVERY_FREE_TEXT';
|
||||
$variablename = 'DELIVERY_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -466,7 +466,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
|
||||
@ -40,14 +40,14 @@ $langs->loadLangs(array("admin", "other", "orders"));
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$type=GETPOST('type', 'alpha');
|
||||
$value=GETPOST('value', 'alpha');
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$type = GETPOST('type', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
|
||||
$specimenthirdparty=new Societe($db);
|
||||
$specimenthirdparty = new Societe($db);
|
||||
$specimenthirdparty->initAsSpecimen();
|
||||
|
||||
|
||||
@ -57,17 +57,17 @@ $specimenthirdparty->initAsSpecimen();
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstinvoice=GETPOST('maskconstinvoice', 'alpha');
|
||||
$maskconstcredit=GETPOST('maskconstcredit', 'alpha');
|
||||
$maskinvoice=GETPOST('maskinvoice', 'alpha');
|
||||
$maskcredit=GETPOST('maskcredit', 'alpha');
|
||||
$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
|
||||
$maskconstcredit = GETPOST('maskconstcredit', 'alpha');
|
||||
$maskinvoice = GETPOST('maskinvoice', 'alpha');
|
||||
$maskcredit = GETPOST('maskcredit', 'alpha');
|
||||
|
||||
if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
|
||||
if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -79,21 +79,21 @@ if ($action == 'updateMask')
|
||||
|
||||
if ($action == 'specimen') // For invoices
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$facture = new FactureFournisseur($db);
|
||||
$facture->initAsSpecimen();
|
||||
$facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier)
|
||||
$facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier)
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -176,13 +176,13 @@ if ($action == 'addcat')
|
||||
|
||||
if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
|
||||
{
|
||||
$freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
|
||||
$res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -197,13 +197,13 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader("", "");
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup');
|
||||
|
||||
print "<br>";
|
||||
@ -237,11 +237,11 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
@ -250,7 +250,7 @@ foreach ($dirmodels as $reldir)
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
|
||||
@ -260,11 +260,11 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) {
|
||||
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
}
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -279,21 +279,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$invoice=new FactureFournisseur($db);
|
||||
$invoice = new FactureFournisseur($db);
|
||||
$invoice->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $invoice);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $invoice);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,15 +325,15 @@ print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
|
||||
$def = array();
|
||||
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = 'invoice_supplier'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = 'invoice_supplier'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -364,17 +364,17 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
|
||||
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new FactureFournisseur($db));
|
||||
@ -382,7 +382,7 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
print "<tr class=\"oddeven\">\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
@ -431,13 +431,13 @@ foreach ($dirmodels as $reldir)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
@ -472,15 +472,15 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print '<td width="80"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='SUPPLIER_INVOICE_FREE_TEXT';
|
||||
$variablename = 'SUPPLIER_INVOICE_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -488,7 +488,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
|
||||
@ -40,13 +40,13 @@ $langs->loadLangs(array("admin", "other", "orders", "stocks"));
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$type=GETPOST('type', 'alpha');
|
||||
$value=GETPOST('value', 'alpha');
|
||||
$type = GETPOST('type', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
|
||||
$specimenthirdparty=new Societe($db);
|
||||
$specimenthirdparty = new Societe($db);
|
||||
$specimenthirdparty->initAsSpecimen();
|
||||
|
||||
|
||||
@ -56,14 +56,14 @@ $specimenthirdparty->initAsSpecimen();
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstorder=GETPOST('maskconstorder', 'alpha');
|
||||
$maskvalue=GETPOST('maskorder', 'alpha');
|
||||
$maskconstorder = GETPOST('maskconstorder', 'alpha');
|
||||
$maskvalue = GETPOST('maskorder', 'alpha');
|
||||
|
||||
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -75,21 +75,21 @@ if ($action == 'updateMask')
|
||||
|
||||
elseif ($action == 'specimen') // For orders
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty=$specimenthirdparty;
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/supplier_order/pdf/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/supplier_order/pdf/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -168,7 +168,7 @@ elseif ($action == 'addcat')
|
||||
|
||||
elseif ($action == 'set_SUPPLIER_ORDER_OTHER')
|
||||
{
|
||||
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED', 'alpha');
|
||||
$doubleapproval = price2num($doubleapproval);
|
||||
|
||||
@ -177,14 +177,14 @@ elseif ($action == 'set_SUPPLIER_ORDER_OTHER')
|
||||
|
||||
// TODO We add/delete permission here until permission can have a condition on a global var
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php';
|
||||
$newmodule=new modFournisseur($db);
|
||||
$newmodule = new modFournisseur($db);
|
||||
|
||||
if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)
|
||||
{
|
||||
// clear default rights array
|
||||
$newmodule->rights=array();
|
||||
$newmodule->rights = array();
|
||||
// add new right
|
||||
$r=0;
|
||||
$r = 0;
|
||||
$newmodule->rights[$r][0] = 1190;
|
||||
$newmodule->rights[$r][1] = $langs->trans("Permission1190");
|
||||
$newmodule->rights[$r][2] = 'w';
|
||||
@ -210,9 +210,9 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER')
|
||||
{
|
||||
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -227,13 +227,13 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER')
|
||||
* View
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader("", "");
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup');
|
||||
|
||||
print "<br>";
|
||||
@ -267,11 +267,11 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
@ -280,7 +280,7 @@ foreach ($dirmodels as $reldir)
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
|
||||
@ -290,11 +290,11 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering module
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) {
|
||||
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
}
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -309,21 +309,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$commande=new CommandeFournisseur($db);
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $commande);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $commande);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,15 +353,15 @@ print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
|
||||
$def = array();
|
||||
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = 'order_supplier'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = 'order_supplier'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -392,15 +392,15 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new CommandeFournisseur($db));
|
||||
@ -408,7 +408,7 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
print "<tr class=\"oddeven\">\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
@ -453,13 +453,13 @@ foreach ($dirmodels as $reldir)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
@ -536,15 +536,15 @@ else
|
||||
}
|
||||
*/
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='SUPPLIER_ORDER_FREE_TEXT';
|
||||
$variablename = 'SUPPLIER_ORDER_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -552,7 +552,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
|
||||
@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "errors", "other", "bills", "orders"));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type='supplier_payment';
|
||||
$type = 'supplier_payment';
|
||||
|
||||
|
||||
/*
|
||||
@ -47,13 +47,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstsupplierpayment=GETPOST('maskconstsupplierpayment', 'alpha');
|
||||
$masksupplierpayment=GETPOST('masksupplierpayment', 'alpha');
|
||||
$maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha');
|
||||
$masksupplierpayment = GETPOST('masksupplierpayment', 'alpha');
|
||||
if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -101,20 +101,20 @@ elseif ($action == 'setdoc')
|
||||
|
||||
elseif ($action == 'specimen')
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$paiementFourn = new PaiementFourn($db);
|
||||
$paiementFourn->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0);
|
||||
$file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -148,14 +148,14 @@ elseif ($action == 'specimen')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader("", $langs->trans("SupplierPaymentSetup"), 'EN:Supplier_Payment_Configuration|FR:Configuration_module_paiement_fournisseur');
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("SupplierPaymentSetup"), $linkback, 'title_setup');
|
||||
|
||||
print "<br>";
|
||||
@ -174,14 +174,14 @@ print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', '');
|
||||
// Load array def with activated templates
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -213,24 +213,24 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
|
||||
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
|
||||
{
|
||||
$filebis = $file;
|
||||
$classname = preg_replace('/\.php$/', '', $file);
|
||||
// For compatibility
|
||||
if (! is_file($dir.$filebis))
|
||||
if (!is_file($dir.$filebis))
|
||||
{
|
||||
$filebis = $file."/".$file.".modules.php";
|
||||
$classname = "mod_supplier_payment_".$file;
|
||||
}
|
||||
// Check if there is a filter on country
|
||||
preg_match('/\-(.*)_(.*)$/', $classname, $reg);
|
||||
if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
|
||||
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
|
||||
|
||||
$classname = preg_replace('/\-.*$/', '', $classname);
|
||||
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
|
||||
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
|
||||
{
|
||||
// Charging the numbering class
|
||||
require_once $dir.$filebis;
|
||||
@ -238,7 +238,7 @@ foreach ($dirmodels as $reldir)
|
||||
$module = new $classname($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
@ -253,9 +253,9 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering module
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -271,21 +271,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$payment=new PaiementFourn($db);
|
||||
$payment = new PaiementFourn($db);
|
||||
$payment->initAsSpecimen();
|
||||
|
||||
// Example
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $payment);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $payment);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= $langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors
|
||||
{
|
||||
if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
|
||||
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
@ -336,24 +336,24 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
|
||||
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new PaiementFourn($db));
|
||||
|
||||
print "<tr class=\"oddeven\">\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
@ -402,11 +402,11 @@ foreach ($dirmodels as $reldir)
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
|
||||
@ -32,15 +32,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "errors", "other", "supplier_proposal"));
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type='supplier_proposal';
|
||||
$type = 'supplier_proposal';
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
@ -51,13 +51,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
$maskconstsupplier_proposal=GETPOST('maskconstsupplier_proposal', 'alpha');
|
||||
$masksupplier_proposal=GETPOST('masksupplier_proposal', 'alpha');
|
||||
$maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'alpha');
|
||||
$masksupplier_proposal = GETPOST('masksupplier_proposal', 'alpha');
|
||||
if ($maskconstsupplier_proposal) $res = dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -69,20 +69,20 @@ if ($action == 'updateMask')
|
||||
|
||||
if ($action == 'specimen')
|
||||
{
|
||||
$modele=GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$supplier_proposal = new SupplierProposal($db);
|
||||
$supplier_proposal->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php");
|
||||
$file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php");
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
@ -117,9 +117,9 @@ if ($action == 'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK')
|
||||
$draft = GETPOST('SUPPLIER_PROPOSAL_DRAFT_WATERMARK', 'alpha');
|
||||
|
||||
$res = dolibarr_set_const($db, "SUPPLIER_PROPOSAL_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -131,13 +131,13 @@ if ($action == 'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK')
|
||||
|
||||
if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT')
|
||||
{
|
||||
$freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
$freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string
|
||||
|
||||
$res = dolibarr_set_const($db, "SUPPLIER_PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -151,9 +151,9 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL')
|
||||
{
|
||||
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
@ -206,16 +206,16 @@ elseif ($action == 'setmod')
|
||||
* Affiche page
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
|
||||
llxHeader('', $langs->trans("SupplierProposalSetup"));
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
//if ($mesg) print $mesg;
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("SupplierProposalSetup"), $linkback, 'title_setup');
|
||||
|
||||
$head = supplier_proposal_admin_prepare_head();
|
||||
@ -246,18 +246,18 @@ foreach ($dirmodels as $reldir)
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 22) == 'mod_supplier_proposal_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||
if (substr($file, 0, 22) == 'mod_supplier_proposal_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.$file.'.php';
|
||||
|
||||
$module = new $file;
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
@ -268,9 +268,9 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
// Show example of numbering module
|
||||
print '<td class="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -287,21 +287,21 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$supplier_proposal=new SupplierProposal($db);
|
||||
$supplier_proposal = new SupplierProposal($db);
|
||||
$supplier_proposal->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc, $supplier_proposal);
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval = $module->getNextValue($mysoc, $supplier_proposal);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
|
||||
$nextval = $langs->trans($nextval);
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,14 +329,14 @@ print load_fiche_titre($langs->trans("SupplierProposalPDFModules"), '', '');
|
||||
// Load array def with activated templates
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
@ -364,42 +364,42 @@ clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('','/doc') as $valdir)
|
||||
foreach (array('', '/doc') as $valdir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/supplier_proposal".$valdir);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
@ -493,18 +493,18 @@ print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
|
||||
print "<td> </td>\n";
|
||||
print "</tr>";
|
||||
|
||||
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
|
||||
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
|
||||
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
|
||||
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
|
||||
$htmltext.='</i>';
|
||||
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
|
||||
$htmltext .= '</i>';
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_SUPPLIER_PROPOSAL_FREE_TEXT">';
|
||||
print '<tr class="oddeven"><td colspan="2">';
|
||||
print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
|
||||
$variablename='SUPPLIER_PROPOSAL_FREE_TEXT';
|
||||
$variablename = 'SUPPLIER_PROPOSAL_FREE_TEXT';
|
||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
{
|
||||
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
|
||||
@ -512,7 +512,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
|
||||
print $doleditor->Create();
|
||||
}
|
||||
print '</td><td class="right">';
|
||||
@ -537,7 +537,7 @@ if ($conf->banque->enabled)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").'</td><td> </td><td class="right">';
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL');
|
||||
}
|
||||
|
||||
@ -28,20 +28,20 @@ require '../../main.inc.php';
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
if (! $user->admin)
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
|
||||
if ($action == 'convert')
|
||||
{
|
||||
$sql="ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
|
||||
$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
|
||||
$db->query($sql);
|
||||
}
|
||||
if ($action == 'convertutf8')
|
||||
{
|
||||
$sql="ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
|
||||
$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ print load_fiche_titre($langs->trans("Tables")." ".ucfirst($conf->db->type), '',
|
||||
|
||||
|
||||
// Define request to get table description
|
||||
$base=0;
|
||||
$base = 0;
|
||||
if (preg_match('/mysql/i', $conf->db->type))
|
||||
{
|
||||
$sql = "SHOW TABLE STATUS";
|
||||
$base=1;
|
||||
$base = 1;
|
||||
}
|
||||
elseif ($conf->db->type == 'pgsql')
|
||||
{
|
||||
$sql = "SELECT conname, contype FROM pg_constraint;";
|
||||
$base=2;
|
||||
$base = 2;
|
||||
}
|
||||
elseif ($conf->db->type == 'mssql')
|
||||
{
|
||||
@ -79,7 +79,7 @@ elseif ($conf->db->type == 'sqlite' || $conf->db->type == 'sqlite3')
|
||||
}
|
||||
|
||||
|
||||
if (! $base)
|
||||
if (!$base)
|
||||
{
|
||||
print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
|
||||
}
|
||||
@ -109,7 +109,7 @@ else
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i=0;
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
@ -161,13 +161,13 @@ else
|
||||
print "</tr>\n";
|
||||
|
||||
$sql = "SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del";
|
||||
$sql.= " FROM pg_stat_user_tables";
|
||||
$sql .= " FROM pg_stat_user_tables";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i=0;
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
@ -202,7 +202,7 @@ else
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
$rescount = $db->query("SELECT COUNT(*) FROM " . $row[0]);
|
||||
$rescount = $db->query("SELECT COUNT(*) FROM ".$row[0]);
|
||||
if ($rescount) {
|
||||
$row_count = $db->fetch_row($rescount);
|
||||
$count = $row_count[0];
|
||||
|
||||
@ -33,21 +33,21 @@ $langs->loadLangs(array('admin', 'members', 'errors'));
|
||||
|
||||
// Choice of print year or current year.
|
||||
$now = dol_now();
|
||||
$year=dol_print_date($now, '%Y');
|
||||
$month=dol_print_date($now, '%m');
|
||||
$day=dol_print_date($now, '%d');
|
||||
$forbarcode=GETPOST('forbarcode');
|
||||
$fk_barcode_type=GETPOST('fk_barcode_type');
|
||||
$mode=GETPOST('mode');
|
||||
$modellabel=GETPOST("modellabel"); // Doc template to use
|
||||
$numberofsticker=GETPOST('numberofsticker', 'int');
|
||||
$year = dol_print_date($now, '%Y');
|
||||
$month = dol_print_date($now, '%m');
|
||||
$day = dol_print_date($now, '%d');
|
||||
$forbarcode = GETPOST('forbarcode');
|
||||
$fk_barcode_type = GETPOST('fk_barcode_type');
|
||||
$mode = GETPOST('mode');
|
||||
$modellabel = GETPOST("modellabel"); // Doc template to use
|
||||
$numberofsticker = GETPOST('numberofsticker', 'int');
|
||||
|
||||
$mesg='';
|
||||
$mesg = '';
|
||||
|
||||
$action=GETPOST('action', 'aZ09');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
$producttmp=new Product($db);
|
||||
$thirdpartytmp=new Societe($db);
|
||||
$producttmp = new Product($db);
|
||||
$thirdpartytmp = new Societe($db);
|
||||
|
||||
|
||||
/*
|
||||
@ -56,14 +56,14 @@ $thirdpartytmp=new Societe($db);
|
||||
|
||||
if (GETPOST('submitproduct') && GETPOST('submitproduct'))
|
||||
{
|
||||
$action=''; // We reset because we don't want to build doc
|
||||
$action = ''; // We reset because we don't want to build doc
|
||||
if (GETPOST('productid') > 0)
|
||||
{
|
||||
$producttmp->fetch(GETPOST('productid'));
|
||||
$forbarcode=$producttmp->barcode;
|
||||
$fk_barcode_type=$producttmp->barcode_type;
|
||||
$forbarcode = $producttmp->barcode;
|
||||
$fk_barcode_type = $producttmp->barcode_type;
|
||||
|
||||
if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
|
||||
if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
|
||||
|
||||
if (empty($forbarcode) || empty($fk_barcode_type))
|
||||
{
|
||||
@ -73,14 +73,14 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct'))
|
||||
}
|
||||
if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty'))
|
||||
{
|
||||
$action=''; // We reset because we don't want to build doc
|
||||
$action = ''; // We reset because we don't want to build doc
|
||||
if (GETPOST('socid') > 0)
|
||||
{
|
||||
$thirdpartytmp->fetch(GETPOST('socid'));
|
||||
$forbarcode=$thirdpartytmp->barcode;
|
||||
$fk_barcode_type=$thirdpartytmp->barcode_type_code;
|
||||
$forbarcode = $thirdpartytmp->barcode;
|
||||
$fk_barcode_type = $thirdpartytmp->barcode_type_code;
|
||||
|
||||
if (empty($fk_barcode_type) && ! empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
|
||||
if (empty($fk_barcode_type) && !empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
|
||||
|
||||
if (empty($forbarcode) || empty($fk_barcode_type))
|
||||
{
|
||||
@ -91,7 +91,7 @@ if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty'))
|
||||
|
||||
if ($action == 'builddoc')
|
||||
{
|
||||
$result=0; $error=0;
|
||||
$result = 0; $error = 0;
|
||||
|
||||
if (empty($forbarcode)) // barcode value
|
||||
{
|
||||
@ -104,12 +104,12 @@ if ($action == 'builddoc')
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
// Get encoder (barcode_type_coder) from barcode type id (barcode_type)
|
||||
$stdobject=new GenericObject($db);
|
||||
$stdobject->barcode_type=$fk_barcode_type;
|
||||
$result=$stdobject->fetch_barcode();
|
||||
$stdobject = new GenericObject($db);
|
||||
$stdobject->barcode_type = $fk_barcode_type;
|
||||
$result = $stdobject->fetch_barcode();
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
@ -117,27 +117,27 @@ if ($action == 'builddoc')
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$code=$forbarcode;
|
||||
$generator=$stdobject->barcode_type_coder; // coder (loaded by fetch_barcode). Engine.
|
||||
$encoding=strtoupper($stdobject->barcode_type_code); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
|
||||
$code = $forbarcode;
|
||||
$generator = $stdobject->barcode_type_coder; // coder (loaded by fetch_barcode). Engine.
|
||||
$encoding = strtoupper($stdobject->barcode_type_code); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
|
||||
|
||||
$diroutput=$conf->barcode->dir_temp;
|
||||
$diroutput = $conf->barcode->dir_temp;
|
||||
dol_mkdir($diroutput);
|
||||
|
||||
// Generate barcode
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
||||
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
foreach ($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir, 0);
|
||||
$newdir=dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
if (!is_dir($newdir)) continue;
|
||||
|
||||
$result=@include_once $newdir.$generator.'.modules.php';
|
||||
$result = @include_once $newdir.$generator.'.modules.php';
|
||||
if ($result) break;
|
||||
}
|
||||
|
||||
@ -151,11 +151,11 @@ if ($action == 'builddoc')
|
||||
$is2d = false;
|
||||
if ($module->encodingIsSupported($encoding))
|
||||
{
|
||||
$barcodeimage=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
|
||||
$barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
|
||||
dol_delete_file($barcodeimage);
|
||||
// File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
|
||||
$result=$module->writeBarCode($code, $encoding, 'Y', 4, 1);
|
||||
if ($result <= 0 || ! dol_is_file($barcodeimage))
|
||||
$result = $module->writeBarCode($code, $encoding, 'Y', 4, 1);
|
||||
if ($result <= 0 || !dol_is_file($barcodeimage))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), null, 'errors');
|
||||
@ -174,10 +174,10 @@ if ($action == 'builddoc')
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
// List of values to scan for a replacement
|
||||
$substitutionarray = array (
|
||||
$substitutionarray = array(
|
||||
'%LOGIN%' => $user->login,
|
||||
'%COMPANY%' => $mysoc->name,
|
||||
'%ADDRESS%' => $mysoc->address,
|
||||
@ -197,17 +197,17 @@ if ($action == 'builddoc')
|
||||
// For labels
|
||||
if ($mode == 'label')
|
||||
{
|
||||
$txtforsticker="%PHOTO%"; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator
|
||||
$textleft=make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT)?$txtforsticker:$conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray);
|
||||
$textheader=make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT)?'':$conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray);
|
||||
$textfooter=make_substitutions((empty($conf->global->BARCODE_LABEL_FOOTER_TEXT)?'':$conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray);
|
||||
$textright=make_substitutions((empty($conf->global->BARCODE_LABEL_RIGHT_TEXT)?'':$conf->global->BARCODE_LABEL_RIGHT_TEXT), $substitutionarray);
|
||||
$forceimgscalewidth=(empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH)?1:$conf->global->BARCODE_FORCEIMGSCALEWIDTH);
|
||||
$forceimgscaleheight=(empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT)?1:$conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
|
||||
$txtforsticker = "%PHOTO%"; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator
|
||||
$textleft = make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT) ? $txtforsticker : $conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray);
|
||||
$textheader = make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT) ? '' : $conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray);
|
||||
$textfooter = make_substitutions((empty($conf->global->BARCODE_LABEL_FOOTER_TEXT) ? '' : $conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray);
|
||||
$textright = make_substitutions((empty($conf->global->BARCODE_LABEL_RIGHT_TEXT) ? '' : $conf->global->BARCODE_LABEL_RIGHT_TEXT), $substitutionarray);
|
||||
$forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH);
|
||||
$forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
|
||||
|
||||
for ($i=0; $i < $numberofsticker; $i++)
|
||||
for ($i = 0; $i < $numberofsticker; $i++)
|
||||
{
|
||||
$arrayofrecords[]=array(
|
||||
$arrayofrecords[] = array(
|
||||
'textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
@ -221,23 +221,23 @@ if ($action == 'builddoc')
|
||||
}
|
||||
|
||||
$i++;
|
||||
$mesg='';
|
||||
$mesg = '';
|
||||
|
||||
// Build and output PDF
|
||||
if ($mode == 'label')
|
||||
{
|
||||
if (! count($arrayofrecords))
|
||||
if (!count($arrayofrecords))
|
||||
{
|
||||
$mesg=$langs->trans("ErrorRecordNotFound");
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($modellabel) || $modellabel == '-1')
|
||||
{
|
||||
$mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
||||
}
|
||||
|
||||
$outfile = $langs->trans("BarCode").'_sheets_'.dol_print_date(dol_now(), 'dayhourlog').'.pdf';
|
||||
|
||||
if (! $mesg) $result=doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile));
|
||||
if (!$mesg) $result = doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile));
|
||||
}
|
||||
|
||||
if ($result <= 0)
|
||||
@ -245,7 +245,7 @@ if ($action == 'builddoc')
|
||||
dol_print_error('', $result);
|
||||
}
|
||||
|
||||
if (! $mesg)
|
||||
if (!$mesg)
|
||||
{
|
||||
$db->close();
|
||||
exit;
|
||||
@ -260,7 +260,7 @@ if ($action == 'builddoc')
|
||||
|
||||
if (empty($conf->barcode->enabled)) accessforbidden();
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('', $langs->trans("BarCodePrintsheet"));
|
||||
|
||||
@ -287,15 +287,15 @@ print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-wid
|
||||
print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' ';
|
||||
print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
|
||||
// List of possible labels (defined into $_Avery_Labels variable set into core/lib/format_cards.lib.php)
|
||||
$arrayoflabels=array();
|
||||
foreach(array_keys($_Avery_Labels) as $codecards)
|
||||
$arrayoflabels = array();
|
||||
foreach (array_keys($_Avery_Labels) as $codecards)
|
||||
{
|
||||
$labeltoshow=$_Avery_Labels[$codecards]['name'];
|
||||
$labeltoshow = $_Avery_Labels[$codecards]['name'];
|
||||
//$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')';
|
||||
$arrayoflabels[$codecards]=$labeltoshow;
|
||||
$arrayoflabels[$codecards] = $labeltoshow;
|
||||
}
|
||||
asort($arrayoflabels);
|
||||
print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
|
||||
print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ?GETPOST('modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
|
||||
print '</div></div>';
|
||||
|
||||
// Number of stickers to print
|
||||
@ -303,7 +303,7 @@ print ' <div class="tagtr">';
|
||||
print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
|
||||
print $langs->trans("NumberOfStickers").' ';
|
||||
print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">';
|
||||
print '<input size="4" type="text" name="numberofsticker" value="'.(GETPOST('numberofsticker')?GETPOST('numberofsticker', 'int'):10).'">';
|
||||
print '<input size="4" type="text" name="numberofsticker" value="'.(GETPOST('numberofsticker') ?GETPOST('numberofsticker', 'int') : 10).'">';
|
||||
print '</div></div>';
|
||||
|
||||
print '</div>';
|
||||
@ -372,12 +372,12 @@ jQuery(document).ready(function() {
|
||||
</script>';
|
||||
|
||||
// Checkbox to select from free text
|
||||
print '<input id="fillmanually" type="radio" '.((! GETPOST("selectorforbarcode") || GETPOST("selectorforbarcode")=='fillmanually')?'checked ':'').'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueManually").' ';
|
||||
print '<input id="fillmanually" type="radio" '.((!GETPOST("selectorforbarcode") || GETPOST("selectorforbarcode") == 'fillmanually') ? 'checked ' : '').'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueManually").' ';
|
||||
print '<br>';
|
||||
|
||||
if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire))
|
||||
if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire))
|
||||
{
|
||||
print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromproduct')?'checked ':'').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").' ';
|
||||
print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode") == 'fillfromproduct') ? 'checked ' : '').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").' ';
|
||||
print '<br>';
|
||||
print '<div class="showforproductselector">';
|
||||
$form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1);
|
||||
@ -385,9 +385,9 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if (! empty($user->rights->societe->lire))
|
||||
if (!empty($user->rights->societe->lire))
|
||||
{
|
||||
print '<input id="fillfromthirdparty" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromthirdparty')?'checked ':'').'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").' ';
|
||||
print '<input id="fillfromthirdparty" type="radio" '.((GETPOST("selectorforbarcode") == 'fillfromthirdparty') ? 'checked ' : '').'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").' ';
|
||||
print '<br>';
|
||||
print '<div class="showforthirdpartyselector">';
|
||||
print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300');
|
||||
@ -435,7 +435,7 @@ print '<br>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br><input class="button" type="submit" id="submitformbarcodegen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode"))?'':'disabled ').'value="'.$langs->trans("BuildPageToPrint").'">';
|
||||
print '<br><input class="button" type="submit" id="submitformbarcodegen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode")) ? '' : 'disabled ').'value="'.$langs->trans("BuildPageToPrint").'">';
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
|
||||
@ -67,12 +67,12 @@ class BlockedLogAuthority
|
||||
|
||||
$this->signature = $block_static->getSignature();
|
||||
|
||||
$blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC') ;
|
||||
$blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC');
|
||||
|
||||
$this->blockchain = '';
|
||||
|
||||
foreach($blocks as &$b) {
|
||||
$this->blockchain.=$b->signature;
|
||||
foreach ($blocks as &$b) {
|
||||
$this->blockchain .= $b->signature;
|
||||
}
|
||||
|
||||
return $this->blockchain;
|
||||
@ -98,7 +98,7 @@ class BlockedLogAuthority
|
||||
public function checkBlockchain($hash)
|
||||
{
|
||||
|
||||
return ($hash === $this->getBlockchainHash() );
|
||||
return ($hash === $this->getBlockchainHash());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +110,7 @@ class BlockedLogAuthority
|
||||
public function addBlock($block)
|
||||
{
|
||||
|
||||
$this->blockchain.=$block;
|
||||
$this->blockchain .= $block;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,14 +122,14 @@ class BlockedLogAuthority
|
||||
public function checkBlock($block)
|
||||
{
|
||||
|
||||
if(strlen($block)!=64) return false;
|
||||
if (strlen($block) != 64) return false;
|
||||
|
||||
$blocks = str_split($this->blockchain, 64);
|
||||
|
||||
if(!in_array($block, $blocks)) {
|
||||
if (!in_array($block, $blocks)) {
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -151,44 +151,44 @@ class BlockedLogAuthority
|
||||
|
||||
if (empty($id) && empty($signature))
|
||||
{
|
||||
$this->error='BadParameter';
|
||||
$this->error = 'BadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$langs->load("blockedlog");
|
||||
|
||||
$sql = "SELECT b.rowid, b.signature, b.blockchain, b.tms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b";
|
||||
|
||||
if ($id) $sql.= " WHERE b.rowid = ". $id;
|
||||
elseif($signature)$sql.= " WHERE b.signature = '". $this->db->escape($signature) ."'" ;
|
||||
if ($id) $sql .= " WHERE b.rowid = ".$id;
|
||||
elseif ($signature)$sql .= " WHERE b.signature = '".$this->db->escape($signature)."'";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->signature = $obj->signature;
|
||||
$this->blockchain = $obj->blockchain;
|
||||
$this->signature = $obj->signature;
|
||||
$this->blockchain = $obj->blockchain;
|
||||
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("RecordNotFound");
|
||||
$this->error = $langs->trans("RecordNotFound");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -202,23 +202,23 @@ class BlockedLogAuthority
|
||||
public function create($user)
|
||||
{
|
||||
|
||||
global $conf,$langs,$hookmanager;
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
$langs->load('blockedlog');
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this).'::create', LOG_DEBUG);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog_authority (";
|
||||
$sql.= " signature,";
|
||||
$sql.= " blockchain";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->signature)."',";
|
||||
$sql.= "'".$this->db->escape($this->blockchain)."'";
|
||||
$sql.= ")";
|
||||
$sql .= " signature,";
|
||||
$sql .= " blockchain";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->escape($this->signature)."',";
|
||||
$sql .= "'".$this->db->escape($this->blockchain)."'";
|
||||
$sql .= ")";
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
@ -241,7 +241,7 @@ class BlockedLogAuthority
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -256,19 +256,19 @@ class BlockedLogAuthority
|
||||
public function update($user)
|
||||
{
|
||||
|
||||
global $conf,$langs,$hookmanager;
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
$langs->load('blockedlog');
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this).'::create', LOG_DEBUG);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."blockedlog_authority SET ";
|
||||
$sql.= " blockchain='".$this->db->escape($this->blockchain)."'";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$sql .= " blockchain='".$this->db->escape($this->blockchain)."'";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
@ -279,7 +279,7 @@ class BlockedLogAuthority
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -296,7 +296,7 @@ class BlockedLogAuthority
|
||||
|
||||
//TODO create cron task on activation
|
||||
|
||||
if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
|
||||
if (empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
|
||||
$this->error = $langs->trans('NoAuthorityURLDefined');
|
||||
return -2;
|
||||
}
|
||||
@ -307,14 +307,14 @@ class BlockedLogAuthority
|
||||
|
||||
$blocks = $block_static->getLog('not_certified', 0, 0, 'rowid', 'ASC');
|
||||
|
||||
$signature=$block_static->getSignature();
|
||||
$signature = $block_static->getSignature();
|
||||
|
||||
foreach($blocks as &$block) {
|
||||
foreach ($blocks as &$block) {
|
||||
$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature;
|
||||
|
||||
$res = file_get_contents($url);
|
||||
echo $block->signature.' '.$url. ' '.$res.'<br>';
|
||||
if($res === 'blockalreadyadded' || $res === 'blockadded') {
|
||||
echo $block->signature.' '.$url.' '.$res.'<br>';
|
||||
if ($res === 'blockalreadyadded' || $res === 'blockadded') {
|
||||
$block->setCertified();
|
||||
}
|
||||
else {
|
||||
|
||||
@ -115,7 +115,7 @@ class BlockedLog
|
||||
public $ref_object = '';
|
||||
|
||||
public $object_data = null;
|
||||
public $user_fullname='';
|
||||
public $user_fullname = '';
|
||||
|
||||
/**
|
||||
* Array of tracked event codes
|
||||
@ -138,14 +138,14 @@ class BlockedLog
|
||||
|
||||
$this->trackedevents = array();
|
||||
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL';
|
||||
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload';
|
||||
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview';
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL';
|
||||
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload';
|
||||
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview';
|
||||
|
||||
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE';
|
||||
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE';
|
||||
|
||||
/* Supplier
|
||||
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate';
|
||||
@ -158,12 +158,12 @@ class BlockedLog
|
||||
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate';
|
||||
*/
|
||||
|
||||
if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DON_DELETE'] = 'logDON_DELETE';
|
||||
//if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL';
|
||||
|
||||
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE';
|
||||
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE';
|
||||
|
||||
/*
|
||||
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate';
|
||||
@ -171,18 +171,18 @@ class BlockedLog
|
||||
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate';
|
||||
*/
|
||||
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY';
|
||||
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE';
|
||||
|
||||
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY';
|
||||
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE';
|
||||
|
||||
// $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules
|
||||
$moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || ! empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
|
||||
if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE']='logCASHCONTROL_VALIDATE';
|
||||
$moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
|
||||
if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,102 +193,102 @@ class BlockedLog
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if($this->element === 'facture') {
|
||||
if ($this->element === 'facture') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
|
||||
$object = new Facture($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
if($this->element === 'invoice_supplier') {
|
||||
if ($this->element === 'invoice_supplier') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
|
||||
$object = new FactureFournisseur($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'payment') {
|
||||
elseif ($this->element === 'payment') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
|
||||
$object = new Paiement($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'payment_supplier') {
|
||||
elseif ($this->element === 'payment_supplier') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
|
||||
$object = new PaiementFourn($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'payment_donation') {
|
||||
elseif ($this->element === 'payment_donation') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
||||
|
||||
$object = new PaymentDonation($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'payment_various') {
|
||||
elseif ($this->element === 'payment_various') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||
|
||||
$object = new PaymentVarious($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'don' || $this->element === 'donation') {
|
||||
elseif ($this->element === 'don' || $this->element === 'donation') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
$object = new Don($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'subscription') {
|
||||
elseif ($this->element === 'subscription') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
|
||||
$object = new Subscription($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
elseif($this->element === 'cashcontrol') {
|
||||
elseif ($this->element === 'cashcontrol') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
|
||||
|
||||
$object = new CashControl($this->db);
|
||||
if ($object->fetch($this->fk_object)>0) {
|
||||
if ($object->fetch($this->fk_object) > 0) {
|
||||
return $object->getNomUrl(1);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$this->error++;
|
||||
}
|
||||
}
|
||||
@ -318,16 +318,16 @@ class BlockedLog
|
||||
{
|
||||
global $langs, $cachedUser;
|
||||
|
||||
if(empty($cachedUser))$cachedUser=array();
|
||||
if (empty($cachedUser))$cachedUser = array();
|
||||
|
||||
if(empty($cachedUser[$this->fk_user])) {
|
||||
$u=new User($this->db);
|
||||
if($u->fetch($this->fk_user)>0) {
|
||||
if (empty($cachedUser[$this->fk_user])) {
|
||||
$u = new User($this->db);
|
||||
if ($u->fetch($this->fk_user) > 0) {
|
||||
$cachedUser[$this->fk_user] = $u;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($cachedUser[$this->fk_user])) {
|
||||
if (!empty($cachedUser[$this->fk_user])) {
|
||||
return $cachedUser[$this->fk_user]->getNomUrl(1);
|
||||
}
|
||||
|
||||
@ -354,25 +354,25 @@ class BlockedLog
|
||||
// action
|
||||
$this->action = $action;
|
||||
// amount
|
||||
$this->amounts= $amounts;
|
||||
$this->amounts = $amounts;
|
||||
// date
|
||||
if ($object->element == 'payment' || $object->element == 'payment_supplier')
|
||||
{
|
||||
$this->date_object = $object->datepaye;
|
||||
}
|
||||
elseif ($object->element=='payment_salary')
|
||||
elseif ($object->element == 'payment_salary')
|
||||
{
|
||||
$this->date_object = $object->datev;
|
||||
}
|
||||
elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
|
||||
{
|
||||
$this->date_object = $object->datepaid?$object->datepaid:$object->datep;
|
||||
$this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
|
||||
}
|
||||
elseif ($object->element=='subscription')
|
||||
elseif ($object->element == 'subscription')
|
||||
{
|
||||
$this->date_object = $object->dateh;
|
||||
}
|
||||
elseif ($object->element=='cashcontrol')
|
||||
elseif ($object->element == 'cashcontrol')
|
||||
{
|
||||
$this->date_object = $object->date_creation;
|
||||
}
|
||||
@ -380,7 +380,7 @@ class BlockedLog
|
||||
$this->date_object = $object->date;
|
||||
}
|
||||
// ref
|
||||
$this->ref_object = ((! empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases
|
||||
$this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases
|
||||
// type of object
|
||||
$this->element = $object->element;
|
||||
// id of object
|
||||
@ -388,11 +388,11 @@ class BlockedLog
|
||||
|
||||
|
||||
// Set object_data
|
||||
$this->object_data=new stdClass();
|
||||
$this->object_data = new stdClass();
|
||||
// Add fields to exclude
|
||||
$arrayoffieldstoexclude = array(
|
||||
'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id',
|
||||
'table_element_line','ismultientitymanaged','isextrafieldmanaged',
|
||||
'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
|
||||
'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged',
|
||||
'linkedObjectsIds',
|
||||
'linkedObjects',
|
||||
'fk_delivery_address',
|
||||
@ -402,48 +402,48 @@ class BlockedLog
|
||||
// Add more fields to exclude depending on object type
|
||||
if ($this->element == 'cashcontrol') {
|
||||
$arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
|
||||
'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code',
|
||||
'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2',
|
||||
'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id',
|
||||
'fk_incoterms','label_incoterms','location_incoterms','lines')
|
||||
'name', 'lastname', 'firstname', 'region', 'region_id', 'region_code', 'state', 'state_id', 'state_code', 'country', 'country_id', 'country_code',
|
||||
'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2',
|
||||
'barcode_type', 'barcode_type_code', 'barcode_type_label', 'barcode_type_coder', 'mode_reglement_id', 'cond_reglement_id', 'mode_reglement', 'cond_reglement', 'shipping_method_id',
|
||||
'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines')
|
||||
);
|
||||
}
|
||||
|
||||
// Add thirdparty info
|
||||
if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty();
|
||||
if (! empty($object->thirdparty))
|
||||
if (!empty($object->thirdparty))
|
||||
{
|
||||
$this->object_data->thirdparty = new stdClass();
|
||||
|
||||
foreach($object->thirdparty as $key=>$value)
|
||||
foreach ($object->thirdparty as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode',
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!in_array($key, array(
|
||||
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
|
||||
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->thirdparty->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Add company info
|
||||
if (! empty($mysoc))
|
||||
if (!empty($mysoc))
|
||||
{
|
||||
$this->object_data->mycompany = new stdClass();
|
||||
|
||||
foreach($mysoc as $key=>$value)
|
||||
foreach ($mysoc as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode',
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!in_array($key, array(
|
||||
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
|
||||
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->mycompany->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Add user info
|
||||
if (! empty($user))
|
||||
if (!empty($user))
|
||||
{
|
||||
$this->fk_user = $user->id;
|
||||
$this->user_fullname = $user->getFullName($langs);
|
||||
@ -452,25 +452,25 @@ class BlockedLog
|
||||
// Field specific to object
|
||||
if ($this->element == 'facture')
|
||||
{
|
||||
foreach($object as $key=>$value)
|
||||
foreach ($object as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','ref_client','ref_supplier','date','datef','datev','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!in_array($key, array(
|
||||
'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if ($key == 'lines')
|
||||
{
|
||||
$lineid=0;
|
||||
foreach($value as $tmpline) // $tmpline is object FactureLine
|
||||
$lineid = 0;
|
||||
foreach ($value as $tmpline) // $tmpline is object FactureLine
|
||||
{
|
||||
$lineid++;
|
||||
foreach($tmpline as $keyline => $valueline)
|
||||
foreach ($tmpline as $keyline => $valueline)
|
||||
{
|
||||
if (! in_array($keyline, array(
|
||||
'ref','multicurrency_code','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','qty','product_type','vat_src_code','tva_tx','info_bits','localtax1_tx','localtax2_tx','total_ht','total_tva','total_ttc','total_localtax1','total_localtax2'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!in_array($keyline, array(
|
||||
'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
|
||||
if (! is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass();
|
||||
if (!is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass();
|
||||
|
||||
$this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
|
||||
}
|
||||
@ -479,43 +479,43 @@ class BlockedLog
|
||||
elseif (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
elseif ($this->element == 'invoice_supplier')
|
||||
{
|
||||
foreach($object as $key=>$value)
|
||||
foreach ($object as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'ref','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!in_array($key, array(
|
||||
'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
|
||||
{
|
||||
$datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep);
|
||||
$paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment);
|
||||
$datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
|
||||
$paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
|
||||
|
||||
$this->object_data->ref = $object->ref;
|
||||
$this->object_data->date = $datepayment;
|
||||
$this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
|
||||
$this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment);
|
||||
$this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment);
|
||||
//$this->object_data->fk_account = $object->fk_account;
|
||||
$this->object_data->note = $object->note;
|
||||
//var_dump($this->object_data);exit;
|
||||
|
||||
$totalamount=0;
|
||||
$totalamount = 0;
|
||||
|
||||
if (! is_array($object->amounts) && $object->amount)
|
||||
if (!is_array($object->amounts) && $object->amount)
|
||||
{
|
||||
$object->amounts=array($object->id => $object->amount);
|
||||
$object->amounts = array($object->id => $object->amount);
|
||||
}
|
||||
|
||||
$paymentpartnumber=0;
|
||||
foreach($object->amounts as $objid => $amount)
|
||||
$paymentpartnumber = 0;
|
||||
foreach ($object->amounts as $objid => $amount)
|
||||
{
|
||||
if (empty($amount)) continue;
|
||||
|
||||
@ -543,7 +543,7 @@ class BlockedLog
|
||||
$tmpobject = new PaymentVarious($this->db);
|
||||
}
|
||||
|
||||
if (! is_object($tmpobject))
|
||||
if (!is_object($tmpobject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -561,12 +561,12 @@ class BlockedLog
|
||||
$paymentpart = new stdClass();
|
||||
$paymentpart->amount = $amount;
|
||||
|
||||
if (! in_array($this->element, array('payment_donation', 'payment_various')))
|
||||
if (!in_array($this->element, array('payment_donation', 'payment_various')))
|
||||
{
|
||||
$result = $tmpobject->fetch_thirdparty();
|
||||
if ($result == 0)
|
||||
{
|
||||
$this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id;
|
||||
$this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id;
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
|
||||
return -1;
|
||||
@ -610,43 +610,43 @@ class BlockedLog
|
||||
}
|
||||
}
|
||||
|
||||
$paymentpartnumber++; // first payment will be 1
|
||||
$paymentpartnumber++; // first payment will be 1
|
||||
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
|
||||
}
|
||||
}
|
||||
|
||||
$this->object_data->amount = $totalamount;
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
elseif($this->element == 'payment_salary')
|
||||
elseif ($this->element == 'payment_salary')
|
||||
{
|
||||
$this->object_data->amounts = array($object->amount);
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
elseif($this->element == 'subscription')
|
||||
elseif ($this->element == 'subscription')
|
||||
{
|
||||
foreach($object as $key=>$value)
|
||||
foreach ($object as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (! in_array($key, array(
|
||||
'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!in_array($key, array(
|
||||
'id', 'datec', 'dateh', 'datef', 'fk_adherent', 'amount', 'import_key', 'statut', 'note'
|
||||
))) continue; // Discard if not into a dedicated list
|
||||
if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
else // Generic case
|
||||
{
|
||||
foreach($object as $key=>$value)
|
||||
foreach ($object as $key=>$value)
|
||||
{
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
|
||||
if (!is_object($value)) $this->object_data->{$key} = $value;
|
||||
}
|
||||
|
||||
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -667,59 +667,59 @@ class BlockedLog
|
||||
|
||||
if (empty($id))
|
||||
{
|
||||
$this->error='BadParameter';
|
||||
$this->error = 'BadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$langs->load("blockedlog");
|
||||
|
||||
$sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
|
||||
$sql.= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b";
|
||||
if ($id) $sql.= " WHERE b.rowid = ". $id;
|
||||
$sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b";
|
||||
if ($id) $sql .= " WHERE b.rowid = ".$id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->entity = $obj->entity;
|
||||
$this->id = $obj->rowid;
|
||||
$this->entity = $obj->entity;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
|
||||
$this->amounts = (double) $obj->amounts;
|
||||
$this->action = $obj->action;
|
||||
$this->action = $obj->action;
|
||||
$this->element = $obj->element;
|
||||
|
||||
$this->fk_object = $obj->fk_object;
|
||||
$this->date_object = $this->db->jdate($obj->date_object);
|
||||
$this->ref_object = $obj->ref_object;
|
||||
$this->fk_object = $obj->fk_object;
|
||||
$this->date_object = $this->db->jdate($obj->date_object);
|
||||
$this->ref_object = $obj->ref_object;
|
||||
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->user_fullname = $obj->user_fullname;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->user_fullname = $obj->user_fullname;
|
||||
|
||||
$this->object_data = $this->dolDecodeBlockedData($obj->object_data);
|
||||
$this->object_data = $this->dolDecodeBlockedData($obj->object_data);
|
||||
|
||||
$this->signature = $obj->signature;
|
||||
$this->signature_line = $obj->signature_line;
|
||||
$this->signature_line = $obj->signature_line;
|
||||
$this->certified = ($obj->certified == 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("RecordNotFound");
|
||||
$this->error = $langs->trans("RecordNotFound");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -739,7 +739,7 @@ class BlockedLog
|
||||
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$aaa = unserialize($data);
|
||||
//$aaa = unserialize($data);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
//print $e->getErrs);
|
||||
}
|
||||
return $aaa;
|
||||
@ -755,7 +755,7 @@ class BlockedLog
|
||||
{
|
||||
|
||||
$res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id);
|
||||
if($res===false) return false;
|
||||
if ($res === false) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -770,82 +770,82 @@ class BlockedLog
|
||||
public function create($user, $forcesignature = '')
|
||||
{
|
||||
|
||||
global $conf,$langs,$hookmanager;
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
$langs->load('blockedlog');
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
// Clean data
|
||||
$this->amounts=(double) $this->amounts;
|
||||
$this->amounts = (double) $this->amounts;
|
||||
|
||||
dol_syslog(get_class($this).'::create action='.$this->action.' fk_user='.$this->fk_user.' user_fullname='.$this->user_fullname, LOG_DEBUG);
|
||||
|
||||
// Check parameters/properties
|
||||
if (! isset($this->amounts)) // amount can be 0 for some events (like when module is disabled)
|
||||
if (!isset($this->amounts)) // amount can be 0 for some events (like when module is disabled)
|
||||
{
|
||||
$this->error=$langs->trans("BlockLogNeedAmountsValue");
|
||||
$this->error = $langs->trans("BlockLogNeedAmountsValue");
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (empty($this->element)) {
|
||||
$this->error=$langs->trans("BlockLogNeedElement");
|
||||
$this->error = $langs->trans("BlockLogNeedElement");
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (empty($this->action)) {
|
||||
$this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog");
|
||||
$this->error = $langs->trans("BadParameterWhenCallingCreateOfBlockedLog");
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -3;
|
||||
}
|
||||
if (empty($this->fk_user)) $this->user_fullname='(Anonymous)';
|
||||
if (empty($this->fk_user)) $this->user_fullname = '(Anonymous)';
|
||||
|
||||
$this->date_creation = dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done
|
||||
$previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done
|
||||
|
||||
$keyforsignature = $this->buildKeyForSignature();
|
||||
|
||||
$this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
|
||||
$this->signature = dol_hash($previoushash . $keyforsignature, '5');
|
||||
$this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
|
||||
$this->signature = dol_hash($previoushash.$keyforsignature, '5');
|
||||
if ($forcesignature) $this->signature = $forcesignature;
|
||||
//var_dump($keyforsignature);var_dump($previoushash);var_dump($this->signature_line);var_dump($this->signature);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog (";
|
||||
$sql.= " date_creation,";
|
||||
$sql.= " action,";
|
||||
$sql.= " amounts,";
|
||||
$sql.= " signature,";
|
||||
$sql.= " signature_line,";
|
||||
$sql.= " element,";
|
||||
$sql.= " fk_object,";
|
||||
$sql.= " date_object,";
|
||||
$sql.= " ref_object,";
|
||||
$sql.= " object_data,";
|
||||
$sql.= " certified,";
|
||||
$sql.= " fk_user,";
|
||||
$sql.= " user_fullname,";
|
||||
$sql.= " entity";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->idate($this->date_creation)."',";
|
||||
$sql.= "'".$this->db->escape($this->action)."',";
|
||||
$sql.= $this->amounts.",";
|
||||
$sql.= "'".$this->db->escape($this->signature)."',";
|
||||
$sql.= "'".$this->db->escape($this->signature_line)."',";
|
||||
$sql.= "'".$this->db->escape($this->element)."',";
|
||||
$sql.= $this->fk_object.",";
|
||||
$sql.= "'".$this->db->idate($this->date_object)."',";
|
||||
$sql.= "'".$this->db->escape($this->ref_object)."',";
|
||||
$sql.= "'".$this->db->escape(serialize($this->object_data))."',";
|
||||
$sql.= "0,";
|
||||
$sql.= $this->fk_user.",";
|
||||
$sql.= "'".$this->db->escape($this->user_fullname)."',";
|
||||
$sql.= ($this->entity ? $this->entity : $conf->entity);
|
||||
$sql.= ")";
|
||||
$sql .= " date_creation,";
|
||||
$sql .= " action,";
|
||||
$sql .= " amounts,";
|
||||
$sql .= " signature,";
|
||||
$sql .= " signature_line,";
|
||||
$sql .= " element,";
|
||||
$sql .= " fk_object,";
|
||||
$sql .= " date_object,";
|
||||
$sql .= " ref_object,";
|
||||
$sql .= " object_data,";
|
||||
$sql .= " certified,";
|
||||
$sql .= " fk_user,";
|
||||
$sql .= " user_fullname,";
|
||||
$sql .= " entity";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->idate($this->date_creation)."',";
|
||||
$sql .= "'".$this->db->escape($this->action)."',";
|
||||
$sql .= $this->amounts.",";
|
||||
$sql .= "'".$this->db->escape($this->signature)."',";
|
||||
$sql .= "'".$this->db->escape($this->signature_line)."',";
|
||||
$sql .= "'".$this->db->escape($this->element)."',";
|
||||
$sql .= $this->fk_object.",";
|
||||
$sql .= "'".$this->db->idate($this->date_object)."',";
|
||||
$sql .= "'".$this->db->escape($this->ref_object)."',";
|
||||
$sql .= "'".$this->db->escape(serialize($this->object_data))."',";
|
||||
$sql .= "0,";
|
||||
$sql .= $this->fk_user.",";
|
||||
$sql .= "'".$this->db->escape($this->user_fullname)."',";
|
||||
$sql .= ($this->entity ? $this->entity : $conf->entity);
|
||||
$sql .= ")";
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
@ -868,7 +868,7 @@ class BlockedLog
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -891,8 +891,8 @@ class BlockedLog
|
||||
// Recalculate hash
|
||||
$keyforsignature = $this->buildKeyForSignature();
|
||||
|
||||
$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
|
||||
$signature = dol_hash($previoushash . $keyforsignature, '5');
|
||||
$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull
|
||||
$signature = dol_hash($previoushash.$keyforsignature, '5');
|
||||
//var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature);
|
||||
|
||||
$res = ($signature === $this->signature);
|
||||
@ -929,13 +929,13 @@ class BlockedLog
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$previoussignature='';
|
||||
$previoussignature = '';
|
||||
|
||||
$sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql.= " WHERE entity=".$conf->entity;
|
||||
if ($beforeid) $sql.= " AND rowid < ".(int) $beforeid;
|
||||
$sql.=" ORDER BY rowid DESC LIMIT 1";
|
||||
$sql.=($withlock ? " FOR UPDATE ": "");
|
||||
$sql .= " WHERE entity=".$conf->entity;
|
||||
if ($beforeid) $sql .= " AND rowid < ".(int) $beforeid;
|
||||
$sql .= " ORDER BY rowid DESC LIMIT 1";
|
||||
$sql .= ($withlock ? " FOR UPDATE " : "");
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
@ -981,38 +981,38 @@ class BlockedLog
|
||||
global $conf, $cachedlogs;
|
||||
|
||||
/* $cachedlogs allow fastest search */
|
||||
if (empty($cachedlogs)) $cachedlogs=array();
|
||||
if (empty($cachedlogs)) $cachedlogs = array();
|
||||
|
||||
if ($element=='all') {
|
||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
if ($element == 'all') {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
WHERE entity=".$conf->entity;
|
||||
}
|
||||
elseif ($element=='not_certified') {
|
||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
elseif ($element == 'not_certified') {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
WHERE entity=".$conf->entity." AND certified = 0";
|
||||
}
|
||||
elseif ($element=='just_certified') {
|
||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
elseif ($element == 'just_certified') {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
WHERE entity=".$conf->entity." AND certified = 1";
|
||||
}
|
||||
else{
|
||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
else {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||
WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object;
|
||||
}
|
||||
|
||||
if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2);
|
||||
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
|
||||
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
|
||||
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
|
||||
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);
|
||||
if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3);
|
||||
if ($search_fk_user > 0) $sql .= natural_search("fk_user", $search_fk_user, 2);
|
||||
if ($search_start > 0) $sql .= " AND date_creation >= '".$this->db->idate($search_start)."'";
|
||||
if ($search_end > 0) $sql .= " AND date_creation <= '".$this->db->idate($search_end)."'";
|
||||
if ($search_ref != '') $sql .= natural_search("ref_object", $search_ref);
|
||||
if ($search_amount != '') $sql .= natural_search("amounts", $search_amount, 1);
|
||||
if ($search_code != '' && $search_code != '-1') $sql .= natural_search("action", $search_code, 3);
|
||||
|
||||
$sql.=$this->db->order($sortfield, $sortorder);
|
||||
$sql.=$this->db->plimit($limit+1); // We want more, because we will stop into loop later with error if we reach max
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->plimit($limit + 1); // We want more, because we will stop into loop later with error if we reach max
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if($res) {
|
||||
$results=array();
|
||||
if ($res) {
|
||||
$results = array();
|
||||
|
||||
$i = 0;
|
||||
while ($obj = $this->db->fetch_object($res))
|
||||
@ -1026,7 +1026,7 @@ class BlockedLog
|
||||
|
||||
if (!isset($cachedlogs[$obj->rowid]))
|
||||
{
|
||||
$b=new BlockedLog($this->db);
|
||||
$b = new BlockedLog($this->db);
|
||||
$b->fetch($obj->rowid);
|
||||
|
||||
$cachedlogs[$obj->rowid] = $b;
|
||||
@ -1048,7 +1048,7 @@ class BlockedLog
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
global $db,$conf,$mysoc;
|
||||
global $db, $conf, $mysoc;
|
||||
|
||||
if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
@ -1059,7 +1059,7 @@ class BlockedLog
|
||||
|
||||
dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity);
|
||||
|
||||
$conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint;
|
||||
$conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
|
||||
}
|
||||
|
||||
return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
|
||||
@ -1079,12 +1079,12 @@ class BlockedLog
|
||||
$result = false;
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
if ($ignoresystem) $sql.=" AND action not in ('MODULE_SET','MODULE_RESET')";
|
||||
$sql.= $this->db->plimit(1);
|
||||
$sql .= " WHERE entity = ".$conf->entity;
|
||||
if ($ignoresystem) $sql .= " AND action not in ('MODULE_SET','MODULE_RESET')";
|
||||
$sql .= $this->db->plimit(1);
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res!==false)
|
||||
if ($res !== false)
|
||||
{
|
||||
$obj = $this->db->fetch_object($res);
|
||||
if ($obj) $result = true;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($langs) || ! is_object($langs))
|
||||
if (empty($langs) || !is_object($langs))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("main","bills","cashdesk"));
|
||||
$langs->loadLangs(array("main", "bills", "cashdesk"));
|
||||
|
||||
?>
|
||||
|
||||
@ -45,18 +45,18 @@ $societe = new Societe($db);
|
||||
$societe->fetch($thirdpartyid);
|
||||
/** end add Ditto */
|
||||
|
||||
$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array());
|
||||
$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array());
|
||||
|
||||
$tab_size=count($tab);
|
||||
$tab_size = count($tab);
|
||||
if ($tab_size <= 0) print '<div class="center">'.$langs->trans("NoArticle").'</div><br>';
|
||||
else
|
||||
{
|
||||
for ($i=0;$i < $tab_size;$i++)
|
||||
for ($i = 0; $i < $tab_size; $i++)
|
||||
{
|
||||
echo ('<div class="cadre_article">'."\n");
|
||||
echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n");
|
||||
|
||||
if ( $tab[$i]['remise_percent'] > 0 ) {
|
||||
if ($tab[$i]['remise_percent'] > 0) {
|
||||
$remise_percent = ' -'.$tab[$i]['remise_percent'].'%';
|
||||
} else {
|
||||
$remise_percent = '';
|
||||
|
||||
@ -17,14 +17,14 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($langs) || ! is_object($langs))
|
||||
if (empty($langs) || !is_object($langs))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("main","bills","banks"));
|
||||
$langs->loadLangs(array("main", "bills", "banks"));
|
||||
|
||||
// Object $form must de defined
|
||||
|
||||
@ -53,30 +53,30 @@ else
|
||||
{
|
||||
case 'ESP':
|
||||
echo $langs->trans("Cash");
|
||||
$filtre='courant=2';
|
||||
$filtre = 'courant=2';
|
||||
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]))
|
||||
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"];
|
||||
break;
|
||||
case 'CB':
|
||||
echo $langs->trans("CreditCard");
|
||||
$filtre='courant=1';
|
||||
$filtre = 'courant=1';
|
||||
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]))
|
||||
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"];
|
||||
break;
|
||||
case 'CHQ':
|
||||
echo $langs->trans("Cheque");
|
||||
$filtre='courant=1';
|
||||
$filtre = 'courant=1';
|
||||
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]))
|
||||
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"];
|
||||
break;
|
||||
case 'DIF':
|
||||
echo $langs->trans("Reported");
|
||||
$filtre='courant=1 OR courant=2';
|
||||
$selected='';
|
||||
$filtre = 'courant=1 OR courant=2';
|
||||
$selected = '';
|
||||
break;
|
||||
default:
|
||||
$filtre='courant=1 OR courant=2';
|
||||
$selected='';
|
||||
$filtre = 'courant=1 OR courant=2';
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
?>
|
||||
@ -103,7 +103,7 @@ if ( $obj_facturation->montantRendu() ) {
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
|
||||
<p class="note_label">
|
||||
<?php
|
||||
echo $langs->trans("BankToPay"). "<br>";
|
||||
echo $langs->trans("BankToPay")."<br>";
|
||||
$form->select_comptes($selected, 'cashdeskbank', 0, $filtre);
|
||||
?>
|
||||
</p>
|
||||
|
||||
@ -107,7 +107,7 @@ class Categorie extends CommonObject
|
||||
'member' => 'member',
|
||||
'contact' => 'socpeople',
|
||||
'user' => 'user',
|
||||
'account' => 'account', // old key for bank_account
|
||||
'account' => 'account', // old key for bank_account
|
||||
'bank_account' => 'account',
|
||||
'project' => 'project',
|
||||
'warehouse'=> 'warehouse',
|
||||
@ -125,7 +125,7 @@ class Categorie extends CommonObject
|
||||
'member' => 'member',
|
||||
'contact' => 'contact',
|
||||
'user' => 'user',
|
||||
'account' => 'account', // old key for bank_account
|
||||
'account' => 'account', // old key for bank_account
|
||||
'bank_account'=> 'account',
|
||||
'project' => 'project',
|
||||
'warehouse'=> 'warehouse',
|
||||
@ -853,29 +853,29 @@ class Categorie extends CommonObject
|
||||
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
if ($type == "customer") {
|
||||
$sub_type = "societe";
|
||||
$subcol_name = "fk_soc";
|
||||
}
|
||||
if ($type=="supplier") {
|
||||
$sub_type="fournisseur";
|
||||
$subcol_name="fk_soc";
|
||||
if ($type == "supplier") {
|
||||
$sub_type = "fournisseur";
|
||||
$subcol_name = "fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
if ($type == "contact") {
|
||||
$subcol_name = "fk_socpeople";
|
||||
}
|
||||
|
||||
$idoftype = array_search($type, self::$MAP_ID_TO_CODE);
|
||||
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||
$sql.= ' AND s.type='.$idoftype;
|
||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql.= ' AND sub.'.$subcol_name.' = '.$id;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||
$sql .= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||
$sql .= ' AND s.type='.$idoftype;
|
||||
$sql .= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql .= ' AND sub.'.$subcol_name.' = '.$id;
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$offset = 0;
|
||||
$nbtotalofrecords = '';
|
||||
@ -897,13 +897,13 @@ class Categorie extends CommonObject
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $this->db->plimit($limit + 1, $offset);
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
@ -1636,8 +1636,8 @@ class Categorie extends CommonObject
|
||||
if (is_array($file['name']) && count($file['name']) > 0)
|
||||
{
|
||||
$nbfile = count($file['name']);
|
||||
for ($i = 0; $i <= $nbfile; $i ++) {
|
||||
$originImage = $dir . $file['name'][$i];
|
||||
for ($i = 0; $i <= $nbfile; $i++) {
|
||||
$originImage = $dir.$file['name'][$i];
|
||||
|
||||
// Cree fichier en taille origine
|
||||
dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0);
|
||||
|
||||
@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
|
||||
$langs->loadlangs(array('categories', 'bills'));
|
||||
|
||||
|
||||
$id=GETPOST('id', 'int');
|
||||
$ref=GETPOST('ref');
|
||||
$type=GETPOST('type');
|
||||
$action=GETPOST('action', 'aZ09');
|
||||
$confirm=GETPOST('confirm');
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref');
|
||||
$type = GETPOST('type');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm');
|
||||
|
||||
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
|
||||
if ($id == "")
|
||||
{
|
||||
@ -66,7 +66,7 @@ if ($id > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if ($object->id) {
|
||||
$file = $_FILES['userfile'];
|
||||
@ -74,15 +74,15 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen
|
||||
{
|
||||
foreach ($file['name'] as $i => $name)
|
||||
{
|
||||
if(empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]) )
|
||||
if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]))
|
||||
{
|
||||
setEventMessage($file['name'][$i] .' : '. $langs->trans(empty($file['tmp_name'][$i])? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles'));
|
||||
setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles'));
|
||||
unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($file['tmp_name'])) {
|
||||
if (!empty($file['tmp_name'])) {
|
||||
$object->add_photo($upload_dir, $file);
|
||||
}
|
||||
}
|
||||
@ -110,15 +110,15 @@ $formother = new FormOther($db);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort");
|
||||
else $title = $langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object, $type);
|
||||
|
||||
@ -181,7 +181,7 @@ if ($object->id)
|
||||
|
||||
if ($action != 'ajout_photo' && $user->rights->categorie->creer)
|
||||
{
|
||||
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
if (!empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
print '<a class="butAction hideonsmartphone" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&id='.$object->id.'&type='.$type.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
@ -198,23 +198,23 @@ if ($object->id)
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*/
|
||||
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0);
|
||||
}
|
||||
|
||||
// Affiche photos
|
||||
if ($action != 'ajout_photo')
|
||||
{
|
||||
$nbphoto=0;
|
||||
$nbbyrow=5;
|
||||
$nbphoto = 0;
|
||||
$nbbyrow = 5;
|
||||
|
||||
$maxWidth = 160;
|
||||
$maxHeight = 120;
|
||||
|
||||
$pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/";
|
||||
$pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/";
|
||||
$dir = $upload_dir.'/'.$pdir;
|
||||
|
||||
$listofphoto = $object->liste_photos($dir);
|
||||
@ -229,22 +229,22 @@ if ($object->id)
|
||||
$nbphoto++;
|
||||
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
||||
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
|
||||
if ($nbbyrow) print '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">';
|
||||
|
||||
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
|
||||
|
||||
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
||||
if ($obj['photo_vignette'])
|
||||
{
|
||||
$filename=$obj['photo_vignette'];
|
||||
$filename = $obj['photo_vignette'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename=$obj['photo'];
|
||||
$filename = $obj['photo'];
|
||||
}
|
||||
|
||||
// Nom affiche
|
||||
$viewfilename=$obj['photo'];
|
||||
$viewfilename = $obj['photo'];
|
||||
|
||||
// Taille de l'image
|
||||
$object->get_image_size($dir.$filename);
|
||||
@ -274,7 +274,7 @@ if ($object->id)
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow)
|
||||
{
|
||||
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||
print '<td width="'.ceil(100 / $nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -35,7 +35,7 @@ class FormAdvTargetEmailing extends Form
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error='';
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -62,15 +62,15 @@ class FormAdvTargetEmailing extends Form
|
||||
$options_array = array();
|
||||
|
||||
$sql = "SELECT code, label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectlevel";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
$sql .= " WHERE active > 0";
|
||||
$sql .= " ORDER BY sortorder";
|
||||
dol_syslog(get_class($this) . '::multiselectProspectionStatus sql=' . $sql, LOG_DEBUG);
|
||||
dol_syslog(get_class($this).'::multiselectProspectionStatus sql='.$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$level = $langs->trans($obj->code);
|
||||
@ -78,7 +78,7 @@ class FormAdvTargetEmailing extends Form
|
||||
$level = $langs->trans($obj->label);
|
||||
$options_array[$obj->code] = $level;
|
||||
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
@ -102,16 +102,16 @@ class FormAdvTargetEmailing extends Form
|
||||
|
||||
$out = '';
|
||||
$countryArray = array();
|
||||
$label = array ();
|
||||
$label = array();
|
||||
|
||||
$options_array = array();
|
||||
|
||||
$sql = "SELECT rowid, code as code_iso, label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_country";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
|
||||
$sql .= " WHERE active = 1 AND code<>''";
|
||||
$sql .= " ORDER BY code ASC";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_country sql=" . $sql);
|
||||
dol_syslog(get_class($this)."::select_country sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -123,9 +123,9 @@ class FormAdvTargetEmailing extends Form
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$countryArray [$i] ['rowid'] = $obj->rowid;
|
||||
$countryArray [$i] ['code_iso'] = $obj->code_iso;
|
||||
$countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
|
||||
$countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
|
||||
$label[$i] = $countryArray[$i]['label'];
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
array_multisort($label, SORT_ASC, $countryArray);
|
||||
@ -133,7 +133,7 @@ class FormAdvTargetEmailing extends Form
|
||||
foreach ($countryArray as $row) {
|
||||
$label = dol_trunc($row['label'], $maxlength, 'middle');
|
||||
if ($row['code_iso'])
|
||||
$label .= ' (' . $row['code_iso'] . ')';
|
||||
$label .= ' ('.$row['code_iso'].')';
|
||||
|
||||
$options_array[$row['rowid']] = $label;
|
||||
}
|
||||
@ -158,23 +158,23 @@ class FormAdvTargetEmailing extends Form
|
||||
|
||||
global $conf;
|
||||
|
||||
$options_array = array ();
|
||||
$options_array = array();
|
||||
|
||||
$sql_usr = '';
|
||||
$sql_usr = '';
|
||||
$sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
|
||||
$sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
|
||||
$sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
|
||||
$sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")";
|
||||
$sql_usr .= " AND u2.rowid = sc.fk_user ";
|
||||
|
||||
if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX))
|
||||
if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX))
|
||||
$sql_usr .= " AND u2.statut<>0 ";
|
||||
$sql_usr .= " ORDER BY name ASC";
|
||||
// print $sql_usr;exit;
|
||||
|
||||
$resql_usr = $this->db->query($sql_usr);
|
||||
if ($resql_usr) {
|
||||
while ( $obj_usr = $this->db->fetch_object($resql_usr) ) {
|
||||
$label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')';
|
||||
while ($obj_usr = $this->db->fetch_object($resql_usr)) {
|
||||
$label = $obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')';
|
||||
|
||||
$options_array [$obj_usr->rowid] = $label;
|
||||
}
|
||||
@ -196,11 +196,11 @@ class FormAdvTargetEmailing extends Form
|
||||
public function multiselectselectLanguage($htmlname = '', $selected_array = array())
|
||||
{
|
||||
|
||||
global $conf,$langs;
|
||||
global $conf, $langs;
|
||||
|
||||
$options_array = array ();
|
||||
$options_array = array();
|
||||
|
||||
$langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
|
||||
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
|
||||
|
||||
foreach ($langs_available as $key => $value)
|
||||
{
|
||||
@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form
|
||||
*/
|
||||
public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array())
|
||||
{
|
||||
$options_array=array();
|
||||
$options_array = array();
|
||||
|
||||
if (is_array($sqlqueryparam))
|
||||
{
|
||||
@ -238,39 +238,39 @@ class FormAdvTargetEmailing extends Form
|
||||
|
||||
if (count($InfoFieldList) >= 3) {
|
||||
if (strpos($InfoFieldList [3], 'extra.') !== false) {
|
||||
$keyList = 'main.' . $InfoFieldList [2] . ' as rowid';
|
||||
$keyList = 'main.'.$InfoFieldList [2].' as rowid';
|
||||
} else {
|
||||
$keyList = $InfoFieldList [2] . ' as rowid';
|
||||
$keyList = $InfoFieldList [2].' as rowid';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1];
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0];
|
||||
if (! empty($InfoFieldList [3])) {
|
||||
$sql = 'SELECT '.$keyList.', '.$InfoFieldList [1];
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList [0];
|
||||
if (!empty($InfoFieldList [3])) {
|
||||
// We have to join on extrafield table
|
||||
if (strpos($InfoFieldList [3], 'extra') !== false) {
|
||||
$sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra';
|
||||
$sql .= ' WHERE extra.fk_object=main.' . $InfoFieldList [2] . ' AND ' . $InfoFieldList [3];
|
||||
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList [0].'_extrafields as extra';
|
||||
$sql .= ' WHERE extra.fk_object=main.'.$InfoFieldList [2].' AND '.$InfoFieldList [3];
|
||||
} else {
|
||||
$sql .= ' WHERE ' . $InfoFieldList [3];
|
||||
$sql .= ' WHERE '.$InfoFieldList [3];
|
||||
}
|
||||
}
|
||||
if (! empty($InfoFieldList[1])) {
|
||||
if (!empty($InfoFieldList[1])) {
|
||||
$sql .= " ORDER BY nom";
|
||||
}
|
||||
// $sql.= ' WHERE entity = '.$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$labeltoshow = dol_trunc($obj->$InfoFieldList [1], 90);
|
||||
$options_array[$obj->rowid]=$labeltoshow;
|
||||
$i ++;
|
||||
$options_array[$obj->rowid] = $labeltoshow;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$this->db->free($resql);
|
||||
@ -289,17 +289,17 @@ class FormAdvTargetEmailing extends Form
|
||||
*/
|
||||
public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array())
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
global $conf, $langs, $user;
|
||||
$langs->load("dict");
|
||||
|
||||
$options_array=array();
|
||||
$options_array = array();
|
||||
|
||||
|
||||
$sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility";
|
||||
$sql.= " WHERE active = 1";
|
||||
$sql .= " WHERE active = 1";
|
||||
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -310,10 +310,10 @@ class FormAdvTargetEmailing extends Form
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$label= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
|
||||
$label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : ''));
|
||||
|
||||
|
||||
$options_array[$obj->code]=$label;
|
||||
$options_array[$obj->code] = $label;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -340,7 +340,7 @@ class FormAdvTargetEmailing extends Form
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$form=new Form($this->db);
|
||||
$form = new Form($this->db);
|
||||
$return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295);
|
||||
return $return;
|
||||
}
|
||||
@ -379,16 +379,16 @@ class FormAdvTargetEmailing extends Form
|
||||
*/
|
||||
public function multiselectCategories($htmlname = '', $selected_array = array(), $type = 0)
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
global $conf, $langs, $user;
|
||||
$langs->load("dict");
|
||||
|
||||
$options_array=array();
|
||||
$options_array = array();
|
||||
|
||||
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."categorie";
|
||||
$sql.= " WHERE type=".$type;
|
||||
$sql .= " WHERE type=".$type;
|
||||
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -399,7 +399,7 @@ class FormAdvTargetEmailing extends Form
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$options_array[$obj->rowid]=$obj->label;
|
||||
$options_array[$obj->rowid] = $obj->label;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -429,32 +429,32 @@ class FormAdvTargetEmailing extends Form
|
||||
$out = '';
|
||||
|
||||
$sql = "SELECT c.rowid, c.name, c.fk_element";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c";
|
||||
$sql .= " WHERE type_element='$type_element'";
|
||||
$sql .= " ORDER BY c.name";
|
||||
|
||||
dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
|
||||
$out .= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
|
||||
if ($showempty)
|
||||
$out .= '<option value=""></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$label = $obj->name;
|
||||
if (empty($label)) {
|
||||
$label=$obj->fk_element;
|
||||
$label = $obj->fk_element;
|
||||
}
|
||||
|
||||
if ($selected > 0 && $selected == $obj->rowid) {
|
||||
$out .= '<option value="' . $obj->rowid . '" selected="selected">' . $label . '</option>';
|
||||
$out .= '<option value="'.$obj->rowid.'" selected="selected">'.$label.'</option>';
|
||||
} else {
|
||||
$out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
|
||||
$out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
||||
}
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -63,18 +63,18 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||
$datep=dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||
$datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||
$datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||
|
||||
$object->accountid=GETPOST("accountid");
|
||||
$object->paymenttype=GETPOST("paiementtype");
|
||||
$object->datev=$datev;
|
||||
$object->datep=$datep;
|
||||
$object->amount=price2num(GETPOST("amount"));
|
||||
$object->label=GETPOST("label");
|
||||
$object->ltt=$lttype;
|
||||
$object->accountid = GETPOST("accountid");
|
||||
$object->paymenttype = GETPOST("paiementtype");
|
||||
$object->datev = $datev;
|
||||
$object->datep = $datep;
|
||||
$object->amount = price2num(GETPOST("amount"));
|
||||
$object->label = GETPOST("label");
|
||||
$object->ltt = $lttype;
|
||||
|
||||
$ret=$object->addPayment($user);
|
||||
$ret = $object->addPayment($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$db->commit();
|
||||
@ -85,27 +85,27 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$_GET["action"]="create";
|
||||
$_GET["action"] = "create";
|
||||
}
|
||||
}
|
||||
|
||||
//delete payment of localtax
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$result=$object->fetch($id);
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($object->rappro == 0)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$ret=$object->delete($user);
|
||||
$ret = $object->delete($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($object->fk_bank)
|
||||
{
|
||||
$accountline=new AccountLine($db);
|
||||
$result=$accountline->fetch($object->fk_bank);
|
||||
if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||
$accountline = new AccountLine($db);
|
||||
$result = $accountline->fetch($object->fk_bank);
|
||||
if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
@ -116,7 +116,7 @@ if ($action == 'delete')
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->error=$accountline->error;
|
||||
$object->error = $accountline->error;
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
@ -129,7 +129,7 @@ if ($action == 'delete')
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='Error try do delete a line linked to a conciliated bank transaction';
|
||||
$mesg = 'Error try do delete a line linked to a conciliated bank transaction';
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
}
|
||||
}
|
||||
@ -151,13 +151,13 @@ if ($id)
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card");
|
||||
$help_url='';
|
||||
$title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card");
|
||||
$help_url = '';
|
||||
llxHeader("", $title, $helpurl);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment", $mysoc->country_code));
|
||||
print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code));
|
||||
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formlocaltax" method="post">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -178,15 +178,15 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth200" value="'.($_POST["label"]?GETPOST("label", '', 2):$langs->transcountry(($lttype==2?"LT2Payment":"LT1Payment"), $mysoc->country_code)).'"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth200" value="'.($_POST["label"] ?GETPOST("label", '', 2) : $langs->transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'"></td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.GETPOST("amount").'"></td></tr>';
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
||||
$form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant
|
||||
$form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
@ -200,8 +200,8 @@ if ($action == 'create')
|
||||
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
|
||||
}
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
@ -254,11 +254,11 @@ if ($id)
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if ($object->fk_account > 0)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($object->fk_bank);
|
||||
|
||||
print '<tr>';
|
||||
@ -271,8 +271,8 @@ if ($id)
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -46,9 +46,9 @@ if ($user->socid > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
||||
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes'))
|
||||
{
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
@ -59,7 +59,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
|
||||
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
|
||||
if (! $_POST["paiementtype"] > 0)
|
||||
if (!$_POST["paiementtype"] > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
|
||||
$error++;
|
||||
@ -71,14 +71,14 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
if (! empty($conf->banque->enabled) && ! ($_POST["accountid"] > 0))
|
||||
if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$paymentid = 0;
|
||||
|
||||
@ -96,10 +96,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
|
||||
$action='create';
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
@ -107,34 +107,34 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
$paiement = new PaymentSocialContribution($db);
|
||||
$paiement->chid = $chid;
|
||||
$paiement->datepaye = $datepaye;
|
||||
$paiement->amounts = $amounts; // Tableau de montant
|
||||
$paiement->amounts = $amounts; // Tableau de montant
|
||||
$paiement->paiementtype = $_POST["paiementtype"];
|
||||
$paiement->num_paiement = $_POST["num_paiement"];
|
||||
$paiement->note = $_POST["note"];
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0));
|
||||
$paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0));
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($paiement->error, null, 'errors');
|
||||
$action='create';
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$result=$paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', '');
|
||||
if (! ($result > 0))
|
||||
$result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', '');
|
||||
if (!($result > 0))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($paiement->error, null, 'errors');
|
||||
$action='create';
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
$loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid;
|
||||
@ -156,7 +156,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
// Formulaire de creation d'un paiement de charge
|
||||
@ -209,12 +209,12 @@ if ($action == 'create')
|
||||
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
|
||||
|
||||
$sql = "SELECT sum(p.amount) as total";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
$sql.= " WHERE p.fk_charge = ".$chid;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
$sql .= " WHERE p.fk_charge = ".$chid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$obj = $db->fetch_object($resql);
|
||||
$sumpaid = $obj->total;
|
||||
$db->free();
|
||||
}
|
||||
@ -223,20 +223,20 @@ if ($action == 'create')
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
|
||||
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0;
|
||||
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype");
|
||||
$form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype");
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td>';
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '', 1); // Show opend bank account list
|
||||
$form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
@ -270,8 +270,8 @@ if ($action == 'create')
|
||||
print '<td align="center">'.$langs->trans("Amount").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$total=0;
|
||||
$totalrecu=0;
|
||||
$total = 0;
|
||||
$totalrecu = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
@ -301,7 +301,7 @@ if ($action == 'create')
|
||||
$nameRemain = "remain_".$objp->id;
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
|
||||
$remaintopay=$objp->amount - $sumpaid;
|
||||
$remaintopay = $objp->amount - $sumpaid;
|
||||
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">';
|
||||
}
|
||||
@ -312,9 +312,9 @@ if ($action == 'create')
|
||||
print "</td>";
|
||||
|
||||
print "</tr>\n";
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$objp->am;
|
||||
$total += $objp->total;
|
||||
$total_ttc += $objp->total_ttc;
|
||||
$totalrecu += $objp->am;
|
||||
$i++;
|
||||
}
|
||||
if ($i > 1)
|
||||
|
||||
@ -34,12 +34,12 @@ class PaymentSocialContribution extends CommonObject
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element='paiementcharge';
|
||||
public $element = 'paiementcharge';
|
||||
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element='paiementcharge';
|
||||
public $table_element = 'paiementcharge';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
@ -51,9 +51,9 @@ class PaymentSocialContribution extends CommonObject
|
||||
*/
|
||||
public $fk_charge;
|
||||
|
||||
public $datec='';
|
||||
public $tms='';
|
||||
public $datep='';
|
||||
public $datec = '';
|
||||
public $tms = '';
|
||||
public $datep = '';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@ -61,8 +61,8 @@ class PaymentSocialContribution extends CommonObject
|
||||
*/
|
||||
public $total;
|
||||
|
||||
public $amount; // Total amount of payment
|
||||
public $amounts=array(); // Array of amounts
|
||||
public $amount; // Total amount of payment
|
||||
public $amounts = array(); // Array of amounts
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
@ -108,28 +108,28 @@ class PaymentSocialContribution extends CommonObject
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$now=dol_now();
|
||||
$now = dol_now();
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
|
||||
// Validate parametres
|
||||
if (! $this->datepaye)
|
||||
if (!$this->datepaye)
|
||||
{
|
||||
$this->error='ErrorBadValueForParameterCreatePaymentSocialContrib';
|
||||
$this->error = 'ErrorBadValueForParameterCreatePaymentSocialContrib';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount=trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement);
|
||||
if (isset($this->note)) $this->note=trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
|
||||
$totalamount = 0;
|
||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||
@ -149,14 +149,14 @@ class PaymentSocialContribution extends CommonObject
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,";
|
||||
$sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
|
||||
$sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||
$sql.= " '".$this->db->idate($this->datepaye)."',";
|
||||
$sql.= " ".$totalamount.",";
|
||||
$sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
||||
$sql.= " 0)";
|
||||
$sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
|
||||
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||
$sql .= " '".$this->db->idate($this->datepaye)."',";
|
||||
$sql .= " ".$totalamount.",";
|
||||
$sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
||||
$sql .= " 0)";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge");
|
||||
@ -172,18 +172,18 @@ class PaymentSocialContribution extends CommonObject
|
||||
// If we want to closed payed invoices
|
||||
if ($closepaidcontrib)
|
||||
{
|
||||
$contrib=new ChargeSociales($this->db);
|
||||
$contrib = new ChargeSociales($this->db);
|
||||
$contrib->fetch($contribid);
|
||||
$paiement = $contrib->getSommePaiement();
|
||||
//$creditnotes=$contrib->getSumCreditNotesUsed();
|
||||
$creditnotes=0;
|
||||
$creditnotes = 0;
|
||||
//$deposits=$contrib->getSumDepositsUsed();
|
||||
$deposits=0;
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT');
|
||||
$remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
|
||||
$deposits = 0;
|
||||
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
|
||||
$remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
|
||||
if ($remaintopay == 0)
|
||||
{
|
||||
$result=$contrib->set_paid($user);
|
||||
$result = $contrib->set_paid($user);
|
||||
}
|
||||
else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
|
||||
}
|
||||
@ -197,18 +197,18 @@ class PaymentSocialContribution extends CommonObject
|
||||
}
|
||||
|
||||
$result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user);
|
||||
if($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
|
||||
if ($totalamount != 0 && ! $error)
|
||||
if ($totalamount != 0 && !$error)
|
||||
{
|
||||
$this->amount=$totalamount;
|
||||
$this->total=$totalamount; // deprecated
|
||||
$this->amount = $totalamount;
|
||||
$this->total = $totalamount; // deprecated
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -278,7 +278,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -294,18 +294,18 @@ class PaymentSocialContribution extends CommonObject
|
||||
public function update($user = null, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount=trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement);
|
||||
if (isset($this->note)) $this->note=trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
|
||||
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement);
|
||||
if (isset($this->note)) $this->note = trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
|
||||
|
||||
|
||||
@ -315,26 +315,26 @@ class PaymentSocialContribution extends CommonObject
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET";
|
||||
|
||||
$sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").",";
|
||||
$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
|
||||
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
|
||||
$sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
|
||||
$sql.= " amount=".(isset($this->amount)?$this->amount:"null").",";
|
||||
$sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").",";
|
||||
$sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").",";
|
||||
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
||||
$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
|
||||
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
|
||||
$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
|
||||
$sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").",";
|
||||
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
|
||||
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
|
||||
$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
|
||||
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
|
||||
$sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").",";
|
||||
$sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").",";
|
||||
$sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
|
||||
$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
|
||||
$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
|
||||
$sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null")."";
|
||||
|
||||
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
|
||||
//if (! $error)
|
||||
//{
|
||||
@ -355,13 +355,13 @@ class PaymentSocialContribution extends CommonObject
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
return -1 * $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -381,7 +381,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::delete");
|
||||
|
||||
@ -392,20 +392,20 @@ class PaymentSocialContribution extends CommonObject
|
||||
$accline = new AccountLine($this->db);
|
||||
$accline->fetch($this->bank_line);
|
||||
$result = $accline->delete();
|
||||
if($result < 0) {
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $accline->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
}
|
||||
|
||||
//if (! $error)
|
||||
@ -427,13 +427,13 @@ class PaymentSocialContribution extends CommonObject
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
return -1 * $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -453,35 +453,35 @@ class PaymentSocialContribution extends CommonObject
|
||||
*/
|
||||
public function createFromClone(User $user, $fromid)
|
||||
{
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$object=new PaymentSocialContribution($this->db);
|
||||
$object = new PaymentSocialContribution($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$object->fetch($fromid);
|
||||
$object->id=0;
|
||||
$object->statut=0;
|
||||
$object->id = 0;
|
||||
$object->statut = 0;
|
||||
|
||||
// Clear fields
|
||||
// ...
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
$result=$object->create($user);
|
||||
$result = $object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$object->error;
|
||||
$this->error = $object->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
unset($object->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
@ -503,19 +503,19 @@ class PaymentSocialContribution extends CommonObject
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
$this->id=0;
|
||||
$this->id = 0;
|
||||
|
||||
$this->fk_charge='';
|
||||
$this->datec='';
|
||||
$this->tms='';
|
||||
$this->datep='';
|
||||
$this->amount='';
|
||||
$this->fk_typepaiement='';
|
||||
$this->num_paiement='';
|
||||
$this->note='';
|
||||
$this->fk_bank='';
|
||||
$this->fk_user_creat='';
|
||||
$this->fk_user_modif='';
|
||||
$this->fk_charge = '';
|
||||
$this->datec = '';
|
||||
$this->tms = '';
|
||||
$this->datep = '';
|
||||
$this->amount = '';
|
||||
$this->fk_typepaiement = '';
|
||||
$this->num_paiement = '';
|
||||
$this->note = '';
|
||||
$this->fk_bank = '';
|
||||
$this->fk_user_creat = '';
|
||||
$this->fk_user_modif = '';
|
||||
}
|
||||
|
||||
|
||||
@ -535,22 +535,22 @@ class PaymentSocialContribution extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$acc->fetch($accountid);
|
||||
|
||||
$total=$this->total;
|
||||
if ($mode == 'payment_sc') $total=-$total;
|
||||
$total = $this->total;
|
||||
if ($mode == 'payment_sc') $total = -$total;
|
||||
|
||||
// Insert payment into llx_bank
|
||||
$bank_line_id = $acc->addline(
|
||||
$this->datepaye,
|
||||
$this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
|
||||
$this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
|
||||
$label,
|
||||
$total,
|
||||
$this->num_paiement,
|
||||
@ -564,7 +564,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
$result=$this->update_fk_bank($bank_line_id);
|
||||
$result = $this->update_fk_bank($bank_line_id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
@ -572,11 +572,11 @@ class PaymentSocialContribution extends CommonObject
|
||||
}
|
||||
|
||||
// Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
|
||||
$url='';
|
||||
if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id=';
|
||||
$url = '';
|
||||
if ($mode == 'payment_sc') $url = DOL_URL_ROOT.'/compta/payment_sc/card.php?id=';
|
||||
if ($url)
|
||||
{
|
||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
@ -635,7 +635,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -663,7 +663,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
|
||||
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
|
||||
|
||||
$langs->load('compta');
|
||||
/*if ($mode == 0)
|
||||
@ -715,18 +715,18 @@ class PaymentSocialContribution extends CommonObject
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result='';
|
||||
$result = '';
|
||||
|
||||
if (empty($this->ref)) $this->ref=$this->lib;
|
||||
if (empty($this->ref)) $this->ref = $this->lib;
|
||||
$label = $langs->trans("ShowPayment").': '.$this->ref;
|
||||
|
||||
if (!empty($this->id)) {
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend='</a>';
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend;
|
||||
if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
|
||||
*/
|
||||
class box_goodcustomers extends ModeleBoxes
|
||||
{
|
||||
public $boxcode="goodcustomers";
|
||||
public $boximg="object_company";
|
||||
public $boxlabel="BoxGoodCustomers";
|
||||
public $boxcode = "goodcustomers";
|
||||
public $boximg = "object_company";
|
||||
public $boxlabel = "BoxGoodCustomers";
|
||||
public $depends = array("societe");
|
||||
|
||||
/**
|
||||
@ -62,10 +62,10 @@ class box_goodcustomers extends ModeleBoxes
|
||||
$this->db = $db;
|
||||
|
||||
// disable box for such cases
|
||||
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option
|
||||
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database
|
||||
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
|
||||
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database
|
||||
|
||||
$this->hidden = ! ($user->rights->societe->lire);
|
||||
$this->hidden = !($user->rights->societe->lire);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,23 +79,23 @@ class box_goodcustomers extends ModeleBoxes
|
||||
global $user, $langs, $conf;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->max=$max;
|
||||
$this->max = $max;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
$thirdpartystatic=new Societe($this->db);
|
||||
$thirdpartystatic = new Societe($this->db);
|
||||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max));
|
||||
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,";
|
||||
$sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
|
||||
$sql.= ' AND s.rowid = f.fk_soc';
|
||||
$sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status";
|
||||
$sql.= $this->db->order("nbfact", "DESC");
|
||||
$sql.= $this->db->plimit($max, 0);
|
||||
$sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
|
||||
$sql .= ' AND s.rowid = f.fk_soc';
|
||||
$sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status";
|
||||
$sql .= $this->db->order("nbfact", "DESC");
|
||||
$sql .= $this->db->plimit($max, 0);
|
||||
|
||||
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -107,7 +107,7 @@ class box_goodcustomers extends ModeleBoxes
|
||||
while ($line < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$datem=$this->db->jdate($objp->tms);
|
||||
$datem = $this->db->jdate($objp->tms);
|
||||
$thirdpartystatic->id = $objp->rowid;
|
||||
$thirdpartystatic->name = $objp->name;
|
||||
$thirdpartystatic->code_client = $objp->code_client;
|
||||
@ -131,7 +131,7 @@ class box_goodcustomers extends ModeleBoxes
|
||||
|
||||
$this->info_box_contents[$line][] = array(
|
||||
'td' => 'class="right"',
|
||||
'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'')
|
||||
'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '')
|
||||
);
|
||||
|
||||
$this->info_box_contents[$line][] = array(
|
||||
@ -142,7 +142,7 @@ class box_goodcustomers extends ModeleBoxes
|
||||
$line++;
|
||||
}
|
||||
|
||||
if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers"));
|
||||
if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"));
|
||||
|
||||
$this->db->free($result);
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
|
||||
*/
|
||||
class box_task extends ModeleBoxes
|
||||
{
|
||||
public $boxcode="projettask";
|
||||
public $boximg="object_projecttask";
|
||||
public $boxcode = "projettask";
|
||||
public $boximg = "object_projecttask";
|
||||
public $boxlabel;
|
||||
public $depends = array("projet");
|
||||
|
||||
@ -42,7 +42,7 @@ class box_task extends ModeleBoxes
|
||||
public $db;
|
||||
|
||||
public $param;
|
||||
public $enabled = 1; // enable because fixed ;-).
|
||||
public $enabled = 1; // enable because fixed ;-).
|
||||
|
||||
public $info_box_head = array();
|
||||
public $info_box_contents = array();
|
||||
@ -61,10 +61,10 @@ class box_task extends ModeleBoxes
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('boxes', 'projects'));
|
||||
|
||||
$this->boxlabel="Tasks";
|
||||
$this->boxlabel = "Tasks";
|
||||
$this->db = $db;
|
||||
|
||||
$this->hidden = ! ($user->rights->projet->lire);
|
||||
$this->hidden = !($user->rights->projet->lire);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,32 +77,32 @@ class box_task extends ModeleBoxes
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$this->max=$max;
|
||||
$this->max = $max;
|
||||
include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php";
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php";
|
||||
$projectstatic = new Project($this->db);
|
||||
$taskstatic=new Task($this->db);
|
||||
$form= new Form($this->db);
|
||||
$cookie_name='boxfilter_task';
|
||||
$boxcontent='';
|
||||
$taskstatic = new Task($this->db);
|
||||
$form = new Form($this->db);
|
||||
$cookie_name = 'boxfilter_task';
|
||||
$boxcontent = '';
|
||||
|
||||
$textHead = $langs->trans("CurentlyOpenedTasks");
|
||||
|
||||
$filterValue='all';
|
||||
if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){
|
||||
$filterValue = 'all';
|
||||
if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) {
|
||||
$filterValue = GETPOST($cookie_name);
|
||||
}
|
||||
elseif(!empty($_COOKIE[$cookie_name])){
|
||||
elseif (!empty($_COOKIE[$cookie_name])) {
|
||||
$filterValue = $_COOKIE[$cookie_name];
|
||||
}
|
||||
|
||||
|
||||
if($filterValue == 'im_task_contact'){
|
||||
$textHead.= ' : '.$langs->trans("WhichIamLinkedTo");
|
||||
if ($filterValue == 'im_task_contact') {
|
||||
$textHead .= ' : '.$langs->trans("WhichIamLinkedTo");
|
||||
}
|
||||
elseif($filterValue == 'im_project_contact'){
|
||||
$textHead.= ' : '.$langs->trans("WhichIamLinkedToProject");
|
||||
elseif ($filterValue == 'im_project_contact') {
|
||||
$textHead .= ' : '.$langs->trans("WhichIamLinkedToProject");
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ class box_task extends ModeleBoxes
|
||||
});
|
||||
</script>';
|
||||
// set cookie by js
|
||||
$boxcontent.='<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
|
||||
$boxcontent .= '<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
|
||||
$this->info_box_contents[0][] = array(
|
||||
'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"',
|
||||
'td' => 'class="nohover"',
|
||||
@ -144,43 +144,43 @@ class box_task extends ModeleBoxes
|
||||
|
||||
|
||||
$sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress";
|
||||
$sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title";
|
||||
$sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title";
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
|
||||
$sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)";
|
||||
|
||||
if($filterValue === 'im_task_contact') {
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '" . $user->id . "' )";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )";
|
||||
if ($filterValue === 'im_task_contact') {
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )";
|
||||
}
|
||||
elseif($filterValue === 'im_project_contact') {
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '" . $user->id . "' )";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )";
|
||||
elseif ($filterValue === 'im_project_contact') {
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )";
|
||||
}
|
||||
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " pt.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
|
||||
$sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
|
||||
$sql.= " AND p.usage_task = 1 ";
|
||||
$sql .= " WHERE ";
|
||||
$sql .= " pt.entity = ".$conf->entity;
|
||||
$sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
|
||||
$sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
|
||||
$sql .= " AND p.usage_task = 1 ";
|
||||
|
||||
|
||||
$sql.= " ORDER BY pt.datee ASC, pt.dateo ASC";
|
||||
$sql.= $this->db->plimit($max, 0);
|
||||
$sql .= " ORDER BY pt.datee ASC, pt.dateo ASC";
|
||||
$sql .= $this->db->plimit($max, 0);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$i = 1;
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($objp = $this->db->fetch_object($result)) {
|
||||
$taskstatic->id=$objp->rowid;
|
||||
$taskstatic->ref=$objp->ref;
|
||||
$taskstatic->label=$objp->label;
|
||||
$taskstatic->id = $objp->rowid;
|
||||
$taskstatic->ref = $objp->ref;
|
||||
$taskstatic->label = $objp->label;
|
||||
$taskstatic->progress = $objp->progress;
|
||||
$taskstatic->fk_statut = $objp->fk_statut;
|
||||
$taskstatic->date_end = $objp->datee;
|
||||
$taskstatic->planned_workload= $objp->planned_workload;
|
||||
$taskstatic->duration_effective= $objp->duration_effective;
|
||||
$taskstatic->planned_workload = $objp->planned_workload;
|
||||
$taskstatic->duration_effective = $objp->duration_effective;
|
||||
|
||||
$projectstatic->id = $objp->project_id;
|
||||
$projectstatic->ref = $objp->project_ref;
|
||||
|
||||
@ -74,9 +74,9 @@ class Link extends CommonObject
|
||||
*/
|
||||
public function create($user = '')
|
||||
{
|
||||
global $langs,$conf;
|
||||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
$langs->load("errors");
|
||||
// Clean parameters
|
||||
if (empty($this->label)) {
|
||||
@ -99,34 +99,34 @@ class Link extends CommonObject
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)";
|
||||
$sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'";
|
||||
$sql .= ", '" . $this->db->escape($this->url) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->label) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->objecttype) . "'";
|
||||
$sql .= ", " . $this->objectid . ")";
|
||||
$sql .= ", '".$this->db->escape($this->url)."'";
|
||||
$sql .= ", '".$this->db->escape($this->label)."'";
|
||||
$sql .= ", '".$this->db->escape($this->objecttype)."'";
|
||||
$sql .= ", ".$this->objectid.")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links");
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."links");
|
||||
|
||||
if ($this->id > 0) {
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINK_CREATE', $user);
|
||||
$result = $this->call_trigger('LINK_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
dol_syslog(get_class($this)."::Create success id=" . $this->id);
|
||||
dol_syslog(get_class($this)."::Create success id=".$this->id);
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::Create echec update ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
@ -135,13 +135,13 @@ class Link extends CommonObject
|
||||
{
|
||||
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name);
|
||||
$result=-1;
|
||||
$this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name);
|
||||
$result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$result=-2;
|
||||
$this->error = $this->db->lasterror();
|
||||
$result = -2;
|
||||
}
|
||||
$this->db->rollback();
|
||||
return $result;
|
||||
@ -157,13 +157,13 @@ class Link extends CommonObject
|
||||
*/
|
||||
public function update($user = '', $call_trigger = 1)
|
||||
{
|
||||
global $langs,$conf;
|
||||
global $langs, $conf;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
$langs->load("errors");
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger);
|
||||
dol_syslog(get_class($this)."::Update id = ".$this->id." call_trigger = ".$call_trigger);
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->url))
|
||||
@ -180,30 +180,30 @@ class Link extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "links SET ";
|
||||
$sql .= "entity = '" . $conf->entity ."'";
|
||||
$sql .= ", datea = '" . $this->db->idate(dol_now()) . "'";
|
||||
$sql .= ", url = '" . $this->db->escape($this->url) . "'";
|
||||
$sql .= ", label = '" . $this->db->escape($this->label) . "'";
|
||||
$sql .= ", objecttype = '" . $this->db->escape($this->objecttype) . "'";
|
||||
$sql .= ", objectid = " . $this->objectid;
|
||||
$sql .= " WHERE rowid = " . $this->id;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."links SET ";
|
||||
$sql .= "entity = '".$conf->entity."'";
|
||||
$sql .= ", datea = '".$this->db->idate(dol_now())."'";
|
||||
$sql .= ", url = '".$this->db->escape($this->url)."'";
|
||||
$sql .= ", label = '".$this->db->escape($this->label)."'";
|
||||
$sql .= ", objecttype = '".$this->db->escape($this->objecttype)."'";
|
||||
$sql .= ", objectid = ".$this->objectid;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update sql = " .$sql);
|
||||
dol_syslog(get_class($this)."::update sql = ".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($call_trigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINK_MODIFY', $user);
|
||||
$result = $this->call_trigger('LINK_MODIFY', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
dol_syslog(get_class($this) . "::Update success");
|
||||
dol_syslog(get_class($this)."::Update success");
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -218,12 +218,12 @@ class Link extends CommonObject
|
||||
{
|
||||
// Doublon
|
||||
$this->error = $langs->trans("ErrorDuplicateField");
|
||||
$result = -1;
|
||||
$result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $langs->trans("Error sql = " . $sql);
|
||||
$result = -2;
|
||||
$this->error = $langs->trans("Error sql = ".$sql);
|
||||
$result = -2;
|
||||
}
|
||||
$this->db->rollback();
|
||||
return $result;
|
||||
@ -244,14 +244,14 @@ class Link extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
|
||||
$sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
|
||||
if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
|
||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links";
|
||||
$sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid;
|
||||
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
|
||||
if ($sortfield) {
|
||||
if (empty($sortorder)) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
$sql .= " ORDER BY " . $sortfield . " " . $sortorder;
|
||||
$sql .= " ORDER BY ".$sortfield." ".$sortorder;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
|
||||
@ -259,7 +259,7 @@ class Link extends CommonObject
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG);
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
@ -295,9 +295,9 @@ class Link extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links";
|
||||
$sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
|
||||
if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links";
|
||||
$sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid;
|
||||
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -322,15 +322,15 @@ class Link extends CommonObject
|
||||
$rowid = $this->id;
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
|
||||
$sql .= " WHERE rowid = " . $rowid;
|
||||
if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
|
||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links";
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if($this->db->num_rows($resql) > 0)
|
||||
if ($this->db->num_rows($resql) > 0)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
@ -348,7 +348,7 @@ class Link extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -367,7 +367,7 @@ class Link extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINK_DELETE', $user);
|
||||
$result = $this->call_trigger('LINK_DELETE', $user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
@ -376,17 +376,17 @@ class Link extends CommonObject
|
||||
// End call triggers
|
||||
|
||||
// Remove link
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "links";
|
||||
$sql.= " WHERE rowid = " . $this->id;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."links";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
if (! $this->db->query($sql))
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
|
||||
return 1;
|
||||
|
||||
@ -118,27 +118,27 @@ class pdf_merou extends ModelePdfExpedition
|
||||
*/
|
||||
public function __construct($db = 0)
|
||||
{
|
||||
global $conf,$langs,$mysoc;
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "merou";
|
||||
$this->description = $langs->trans("DocumentModelMerou");
|
||||
|
||||
$this->type = 'pdf';
|
||||
$formatarray=pdf_getFormat();
|
||||
$formatarray = pdf_getFormat();
|
||||
$this->page_largeur = $formatarray['width'];
|
||||
$this->page_hauteur = round($formatarray['height']/2);
|
||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||
$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
|
||||
$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
|
||||
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
|
||||
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
|
||||
$this->page_hauteur = round($formatarray['height'] / 2);
|
||||
$this->format = array($this->page_largeur, $this->page_hauteur);
|
||||
$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
|
||||
$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
|
||||
$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
|
||||
$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
|
||||
|
||||
$this->option_logo = 1; // Display logo
|
||||
$this->option_logo = 1; // Display logo
|
||||
|
||||
// Get source company
|
||||
$this->emetteur=$mysoc;
|
||||
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
|
||||
$this->emetteur = $mysoc;
|
||||
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
|
||||
}
|
||||
|
||||
|
||||
@ -157,13 +157,13 @@ class pdf_merou extends ModelePdfExpedition
|
||||
public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user,$conf,$langs,$mysoc,$hookmanager;
|
||||
global $user, $conf, $langs, $mysoc, $hookmanager;
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
if (!is_object($outputlangs)) $outputlangs = $langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
|
||||
if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
|
||||
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
|
||||
@ -180,31 +180,31 @@ class pdf_merou extends ModelePdfExpedition
|
||||
//Create recipient
|
||||
$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
|
||||
$this->destinataire = new Contact($this->db);
|
||||
if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
|
||||
if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
|
||||
|
||||
//Create deliverer
|
||||
$idcontact = $object->$origin->getIdContact('internal', 'LIVREUR');
|
||||
$this->livreur = new User($this->db);
|
||||
if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
|
||||
if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
|
||||
|
||||
// Definition of $dir and $file
|
||||
if ($object->specimen)
|
||||
{
|
||||
$dir = $conf->expedition->dir_output."/sending";
|
||||
$file = $dir . "/SPECIMEN.pdf";
|
||||
$file = $dir."/SPECIMEN.pdf";
|
||||
}
|
||||
else
|
||||
{
|
||||
$expref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->expedition->dir_output . "/sending/" . $expref;
|
||||
$file = $dir . "/" . $expref . ".pdf";
|
||||
$dir = $conf->expedition->dir_output."/sending/".$expref;
|
||||
$file = $dir."/".$expref.".pdf";
|
||||
}
|
||||
|
||||
if (! file_exists($dir))
|
||||
if (!file_exists($dir))
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -212,24 +212,24 @@ class pdf_merou extends ModelePdfExpedition
|
||||
if (file_exists($dir))
|
||||
{
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
if (!is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$nblines = count($object->lines);
|
||||
|
||||
$pdf=pdf_getInstance($this->format, 'mm', 'l');
|
||||
$pdf = pdf_getInstance($this->format, 'mm', 'l');
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
$heightforinfotot = 0; // Height reserved to output the info and total part
|
||||
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
|
||||
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
|
||||
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
|
||||
$heightforinfotot = 0; // Height reserved to output the info and total part
|
||||
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
|
||||
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
|
||||
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
|
||||
$pdf->SetAutoPageBreak(1, 0);
|
||||
|
||||
if (class_exists('TCPDF'))
|
||||
@ -239,14 +239,14 @@ class pdf_merou extends ModelePdfExpedition
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
// Set path to the background PDF File
|
||||
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
|
||||
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
|
||||
{
|
||||
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
|
||||
$tplidx = $pdf->importPage(1);
|
||||
}
|
||||
|
||||
$pdf->Open();
|
||||
$pagenb=0;
|
||||
$pagenb = 0;
|
||||
$pdf->SetDrawColor(128, 128, 128);
|
||||
|
||||
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
|
||||
@ -256,41 +256,41 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
|
||||
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
$pagenb++;
|
||||
$this->_pagehead($pdf, $object, 1, $outputlangs);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
$tab_top = 52;
|
||||
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
|
||||
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
|
||||
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
|
||||
$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
|
||||
|
||||
// Display notes
|
||||
if (! empty($object->note_public))
|
||||
if (!empty($object->note_public))
|
||||
{
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
$height_note=$nexY-$tab_top;
|
||||
$height_note = $nexY - $tab_top;
|
||||
|
||||
// Rect takes a length in 3rd parameter
|
||||
$pdf->SetDrawColor(192, 192, 192);
|
||||
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
|
||||
$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
|
||||
|
||||
$tab_height = $tab_height - $height_note;
|
||||
$tab_top = $nexY+6;
|
||||
$tab_top = $nexY + 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
$height_note=0;
|
||||
$height_note = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -302,7 +302,7 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$curY = $tab_top + 7;
|
||||
$nexY = $tab_top + 7;
|
||||
|
||||
$num=count($object->lines);
|
||||
$num = count($object->lines);
|
||||
// Loop on each lines
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
@ -311,17 +311,17 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
$pdf->setTopMargin($tab_top_newpage);
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
$pageposbefore=$pdf->getPage();
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
$pageposbefore = $pdf->getPage();
|
||||
|
||||
// Description of product line
|
||||
$libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
|
||||
|
||||
$nexY = $pdf->GetY();
|
||||
$pageposafter=$pdf->getPage();
|
||||
$pageposafter = $pdf->getPage();
|
||||
$pdf->setPage($pageposbefore);
|
||||
$pdf->setTopMargin($this->marge_haute);
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
|
||||
// We suppose that a too long description is moved completely on next page
|
||||
if ($pageposafter > $pageposbefore) {
|
||||
@ -332,8 +332,8 @@ class pdf_merou extends ModelePdfExpedition
|
||||
|
||||
// Check boxes
|
||||
$pdf->SetDrawColor(120, 120, 120);
|
||||
$pdf->Rect(10+3, $curY, 3, 3);
|
||||
$pdf->Rect(20+3, $curY, 3, 3);
|
||||
$pdf->Rect(10 + 3, $curY, 3, 3);
|
||||
$pdf->Rect(20 + 3, $curY, 3, 3);
|
||||
|
||||
//Inserting the product reference
|
||||
$pdf->SetXY(30, $curY);
|
||||
@ -347,16 +347,16 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
|
||||
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
|
||||
{
|
||||
$pdf->setPage($pageposafter);
|
||||
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
|
||||
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
|
||||
//$pdf->SetDrawColor(190,190,200);
|
||||
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
|
||||
$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
|
||||
$pdf->SetLineStyle(array('dash'=>0));
|
||||
}
|
||||
|
||||
$nexY+=2; // Add space between lines
|
||||
$nexY += 2; // Add space between lines
|
||||
|
||||
// Detect if some page were added automatically and output _tableau for past pages
|
||||
while ($pagenb < $pageposafter)
|
||||
@ -373,9 +373,9 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$this->_pagefoot($pdf, $object, $outputlangs, 1);
|
||||
$pagenb++;
|
||||
$pdf->setPage($pagenb);
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
}
|
||||
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
|
||||
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
|
||||
{
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
@ -396,12 +396,12 @@ class pdf_merou extends ModelePdfExpedition
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
|
||||
// Pagefoot
|
||||
@ -413,22 +413,22 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->Output($file, 'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
if (!is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0)
|
||||
{
|
||||
$this->error = $hookmanager->error;
|
||||
$this->errors = $hookmanager->errors;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
@ -437,13 +437,13 @@ class pdf_merou extends ModelePdfExpedition
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
|
||||
$this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -531,20 +531,20 @@ class pdf_merou extends ModelePdfExpedition
|
||||
*/
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
|
||||
{
|
||||
global $conf, $langs,$hookmanager;
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
|
||||
|
||||
//Affiche le filigrane brouillon - Print Draft Watermark
|
||||
if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
|
||||
if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
|
||||
{
|
||||
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
|
||||
}
|
||||
|
||||
$posy=$this->marge_haute;
|
||||
$posx=$this->page_largeur-$this->marge_droite-100;
|
||||
$posy = $this->marge_haute;
|
||||
$posx = $this->page_largeur - $this->marge_droite - 100;
|
||||
|
||||
$Xoff = 90;
|
||||
$Yoff = 0;
|
||||
@ -556,13 +556,13 @@ class pdf_merou extends ModelePdfExpedition
|
||||
|
||||
//*********************LOGO****************************
|
||||
$pdf->SetXY(11, 7);
|
||||
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
|
||||
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
|
||||
if ($this->emetteur->logo)
|
||||
{
|
||||
if (is_readable($logo))
|
||||
{
|
||||
$height=pdf_getHeightForLogo($logo);
|
||||
$pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
|
||||
$height = pdf_getHeightForLogo($logo);
|
||||
$pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -574,7 +574,7 @@ class pdf_merou extends ModelePdfExpedition
|
||||
}
|
||||
else
|
||||
{
|
||||
$text=$this->emetteur->name;
|
||||
$text = $this->emetteur->name;
|
||||
$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
|
||||
@ -583,9 +583,9 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->SetXY($Xoff, 7);
|
||||
$pdf->SetFont('', 'B', $default_font_size + 2);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
|
||||
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
|
||||
//Num Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$Yoff = $Yoff + 7;
|
||||
$Xoff = 142;
|
||||
//$pdf->Rect($Xoff, $Yoff, 85, 8);
|
||||
$pdf->SetXY($Xoff, $Yoff);
|
||||
@ -594,8 +594,8 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
|
||||
//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
|
||||
$origin = $object->origin;
|
||||
$origin_id = $object->origin_id;
|
||||
$origin = $object->origin;
|
||||
$origin_id = $object->origin_id;
|
||||
|
||||
// Add list of linked elements
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
|
||||
@ -603,15 +603,15 @@ class pdf_merou extends ModelePdfExpedition
|
||||
//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
//Definition Location of the Company block
|
||||
$Xoff = 110;
|
||||
$blSocX=90;
|
||||
$blSocY=24;
|
||||
$blSocW=50;
|
||||
$blSocX2=$blSocW+$blSocX;
|
||||
$blSocX = 90;
|
||||
$blSocY = 24;
|
||||
$blSocW = 50;
|
||||
$blSocX2 = $blSocW + $blSocX;
|
||||
|
||||
// Sender name
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetXY($blSocX, $blSocY+1);
|
||||
$pdf->SetXY($blSocX, $blSocY + 1);
|
||||
$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
@ -619,54 +619,54 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetXY($blSocX, $blSocY+4);
|
||||
$pdf->SetXY($blSocX, $blSocY + 4);
|
||||
$pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
|
||||
|
||||
|
||||
if ($object->thirdparty->code_client)
|
||||
{
|
||||
$Yoff+=3;
|
||||
$posy=$Yoff;
|
||||
$Yoff += 3;
|
||||
$posy = $Yoff;
|
||||
$pdf->SetXY(100, $posy);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
}
|
||||
|
||||
// Date delivery
|
||||
$Yoff = $Yoff+7;
|
||||
$pdf->SetXY($blSocX-80, $blSocY+17);
|
||||
$Yoff = $Yoff + 7;
|
||||
$pdf->SetXY($blSocX - 80, $blSocY + 17);
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
|
||||
|
||||
$pdf->SetXY($blSocX-80, $blSocY+20);
|
||||
$pdf->SetXY($blSocX - 80, $blSocY + 20);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
|
||||
|
||||
// Deliverer
|
||||
$pdf->SetXY($blSocX-80, $blSocY+23);
|
||||
$pdf->SetXY($blSocX - 80, $blSocY + 23);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
if (! empty($object->tracking_number))
|
||||
if (!empty($object->tracking_number))
|
||||
{
|
||||
$object->getUrlTrackingStatus($object->tracking_number);
|
||||
if (! empty($object->tracking_url))
|
||||
if (!empty($object->tracking_url))
|
||||
{
|
||||
if ($object->shipping_method_id > 0)
|
||||
{
|
||||
// Get code using getLabelFromKey
|
||||
$code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
|
||||
$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
|
||||
|
||||
$label='';
|
||||
$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
|
||||
$label = '';
|
||||
$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
|
||||
//var_dump($object->tracking_url != $object->tracking_number);exit;
|
||||
if ($object->tracking_url != $object->tracking_number)
|
||||
{
|
||||
$label.=" : ";
|
||||
$label.=$object->tracking_url;
|
||||
$label .= " : ";
|
||||
$label .= $object->tracking_url;
|
||||
}
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
|
||||
@ -681,20 +681,20 @@ class pdf_merou extends ModelePdfExpedition
|
||||
|
||||
// Shipping company (My Company)
|
||||
$Yoff = $blSocY;
|
||||
$blExpX=$Xoff-20;
|
||||
$blW=52;
|
||||
$blExpX = $Xoff - 20;
|
||||
$blW = 52;
|
||||
$Ydef = $Yoff;
|
||||
$pdf->Rect($blExpX, $Yoff, $blW, 26);
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
// If SHIPPING contact defined on order, we use it
|
||||
$usecontact=false;
|
||||
$arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING');
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
$usecontact=true;
|
||||
$result=$object->fetch_contact($arrayidcontact[0]);
|
||||
$usecontact = true;
|
||||
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
|
||||
// Recipient name
|
||||
@ -705,19 +705,19 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$thirdparty = $object->thirdparty;
|
||||
}
|
||||
|
||||
$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
|
||||
$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact))?$object->contact:null), $usecontact, 'targetwithdetails', $object);
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
|
||||
|
||||
$blDestX=$blExpX+55;
|
||||
$blW=54;
|
||||
$Yoff = $Ydef +1;
|
||||
$blDestX = $blExpX + 55;
|
||||
$blW = 54;
|
||||
$Yoff = $Ydef + 1;
|
||||
|
||||
// Show Recipient frame
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetXY($blDestX, $Yoff-4);
|
||||
$pdf->SetXY($blDestX, $Yoff - 4);
|
||||
$pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
|
||||
$pdf->Rect($blDestX, $Yoff-1, $blW, 26);
|
||||
$pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
|
||||
|
||||
// Show recipient name
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@
|
||||
* \brief File to manage password generation according to standard rule
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -61,10 +61,10 @@ class modGeneratePassStandard extends ModeleGenPassword
|
||||
$this->id = "standard";
|
||||
$this->length = 8;
|
||||
|
||||
$this->db=$db;
|
||||
$this->conf=$conf;
|
||||
$this->langs=$langs;
|
||||
$this->user=$user;
|
||||
$this->db = $db;
|
||||
$this->conf = $conf;
|
||||
$this->langs = $langs;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ class modGeneratePassStandard extends ModeleGenPassword
|
||||
while ($i < $this->length)
|
||||
{
|
||||
// pick a random character from the possible ones
|
||||
$char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1);
|
||||
$char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1);
|
||||
|
||||
// we don't want this character if it's already in the password
|
||||
if (!strstr($password, $char))
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || ! is_object($object))
|
||||
if (empty($object) || !is_object($object))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
@ -35,28 +35,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
$module = $object->element;
|
||||
|
||||
// Special cases
|
||||
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
|
||||
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
|
||||
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
|
||||
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
|
||||
elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
|
||||
elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
|
||||
elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
|
||||
elseif ($module == 'reception') { $permission=$user->rights->reception->creer; }
|
||||
elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
|
||||
elseif (! isset($permission) && isset($user->rights->$module->creer))
|
||||
if ($module == 'propal') { $permission = $user->rights->propale->creer; }
|
||||
elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; }
|
||||
elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; }
|
||||
elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; }
|
||||
elseif ($module == 'project') { $permission = $user->rights->projet->creer; }
|
||||
elseif ($module == 'action') { $permission = $user->rights->agenda->myactions->create; }
|
||||
elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; }
|
||||
elseif ($module == 'reception') { $permission = $user->rights->reception->creer; }
|
||||
elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; }
|
||||
elseif (!isset($permission) && isset($user->rights->$module->creer))
|
||||
{
|
||||
$permission=$user->rights->$module->creer;
|
||||
$permission = $user->rights->$module->creer;
|
||||
}
|
||||
elseif (! isset($permission) && isset($user->rights->$module->write))
|
||||
elseif (!isset($permission) && isset($user->rights->$module->write))
|
||||
{
|
||||
$permission=$user->rights->$module->write;
|
||||
$permission = $user->rights->$module->write;
|
||||
}
|
||||
|
||||
$formcompany= new FormCompany($db);
|
||||
$companystatic=new Societe($db);
|
||||
$contactstatic=new Contact($db);
|
||||
$userstatic=new User($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
$companystatic = new Societe($db);
|
||||
$contactstatic = new Contact($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
?>
|
||||
|
||||
@ -90,11 +90,11 @@ if ($permission) {
|
||||
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
|
||||
<div class="nowrap tagtd"><?php echo img_object('', 'user').' '.$langs->trans("Users"); ?></div>
|
||||
<div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
|
||||
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
|
||||
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
|
||||
<div class="tagtd maxwidthonsmartphone">
|
||||
<?php
|
||||
$tmpobject=$object;
|
||||
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
|
||||
$tmpobject = $object;
|
||||
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
|
||||
echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal');
|
||||
?></div>
|
||||
<div class="tagtd"> </div>
|
||||
@ -116,7 +116,7 @@ if ($permission) {
|
||||
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
|
||||
<div class="tagtd nowrap noborderbottom"><?php echo img_object('', 'contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
|
||||
<div class="tagtd nowrap maxwidthonsmartphone noborderbottom">
|
||||
<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
|
||||
<?php $selectedCompany = isset($_GET["newcompany"]) ? $_GET["newcompany"] : $object->socid; ?>
|
||||
<?php
|
||||
// add company icon before select list
|
||||
if ($selectedCompany)
|
||||
|
||||
@ -29,77 +29,77 @@ $isInvoice = in_array($object->element, array('facture', 'invoice', 'facture_fou
|
||||
$isNewObject = empty($object->id) && empty($object->rowid);
|
||||
|
||||
// Relative and absolute discounts
|
||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditRelativeDiscount") . '</a>';
|
||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
||||
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
||||
$addrelativediscount = '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditRelativeDiscount").'</a>';
|
||||
$addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditGlobalDiscounts").'</a>';
|
||||
$viewabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("ViewAvailableGlobalDiscounts").'</a>';
|
||||
|
||||
$fixedDiscount = $thirdparty->remise_percent;
|
||||
if(! empty($discount_type)) {
|
||||
if (!empty($discount_type)) {
|
||||
$fixedDiscount = $thirdparty->remise_supplier_percent;
|
||||
}
|
||||
|
||||
if ($fixedDiscount > 0)
|
||||
{
|
||||
$translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
|
||||
$translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
|
||||
print $langs->trans($translationKey, $fixedDiscount).'.';
|
||||
}
|
||||
else
|
||||
{
|
||||
$translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
|
||||
$translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
|
||||
print $langs->trans($translationKey).'.';
|
||||
}
|
||||
if($isNewObject) print ' ('.$addrelativediscount.')';
|
||||
if ($isNewObject) print ' ('.$addrelativediscount.')';
|
||||
|
||||
// Is there is commercial discount or down payment available ?
|
||||
if ($absolute_discount > 0) {
|
||||
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
|
||||
$translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
|
||||
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.';
|
||||
if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
|
||||
$translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
|
||||
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.';
|
||||
|
||||
if ($isInvoice && ! $isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
|
||||
if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
|
||||
$text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse'));
|
||||
}
|
||||
|
||||
if ($isNewObject) {
|
||||
$text.= ' ('.$addabsolutediscount.')';
|
||||
$text .= ' ('.$addabsolutediscount.')';
|
||||
}
|
||||
|
||||
print '<br>'.$text;
|
||||
} else {
|
||||
// Discount available of type fixed amount (not credit note)
|
||||
$more = '(' . $addabsolutediscount . ')';
|
||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
|
||||
$more = '('.$addabsolutediscount.')';
|
||||
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
|
||||
}
|
||||
}
|
||||
|
||||
// Is there credit notes availables ?
|
||||
if ($absolute_creditnote > 0) {
|
||||
// If validated, we show link "add credit note to payment"
|
||||
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) {
|
||||
$translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
|
||||
$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
||||
if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) {
|
||||
$translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
|
||||
$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.';
|
||||
|
||||
if ($isInvoice && ! $isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) {
|
||||
if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) {
|
||||
$text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse'));
|
||||
}
|
||||
|
||||
if ($absolute_discount <= 0 || $isNewObject) {
|
||||
$text.= '('.$addabsolutediscount.')';
|
||||
$text .= '('.$addabsolutediscount.')';
|
||||
}
|
||||
|
||||
print '<br>'.$text;
|
||||
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
||||
// There is credit notes discounts available
|
||||
$more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : '';
|
||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
|
||||
$more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : '';
|
||||
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
|
||||
}
|
||||
}
|
||||
|
||||
if($absolute_discount <= 0 && $absolute_creditnote <= 0) {
|
||||
$translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
|
||||
if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
|
||||
$translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
|
||||
print '<br>'.$langs->trans($translationKey).'.';
|
||||
|
||||
if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
|
||||
print ' (' . $addabsolutediscount . ')';
|
||||
print ' ('.$addabsolutediscount.')';
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,59 +33,59 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || ! is_object($object)) {
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error: this template page cannot be called directly as an URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande')))
|
||||
$usemargins = 0;
|
||||
if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')))
|
||||
{
|
||||
$usemargins=1;
|
||||
$usemargins = 1;
|
||||
}
|
||||
|
||||
if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
|
||||
if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
|
||||
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
|
||||
|
||||
if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility
|
||||
elseif (empty($dateSelector)) $dateSelector=0;
|
||||
if (empty($forceall)) $forceall=0;
|
||||
if (empty($senderissupplier)) $senderissupplier=0;
|
||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||
if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility
|
||||
elseif (empty($dateSelector)) $dateSelector = 0;
|
||||
if (empty($forceall)) $forceall = 0;
|
||||
if (empty($senderissupplier)) $senderissupplier = 0;
|
||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0;
|
||||
|
||||
|
||||
// Define colspan for the button 'Add'
|
||||
$colspan = 3; // Columns: total ht + col edit + col delete
|
||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required
|
||||
if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||
$colspan = 3; // Columns: total ht + col edit + col delete
|
||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required
|
||||
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||
//print $object->element;
|
||||
|
||||
// Lines for extrafield
|
||||
$objectline = null;
|
||||
if (!empty($extrafields))
|
||||
{
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
if ($this->table_element_line == 'commandedet') {
|
||||
$objectline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
elseif ($this->table_element_line == 'propaldet') {
|
||||
$objectline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='supplier_proposaldet') {
|
||||
elseif ($this->table_element_line == 'supplier_proposaldet') {
|
||||
$objectline = new SupplierProposalLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
elseif ($this->table_element_line == 'facturedet') {
|
||||
$objectline = new FactureLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='contratdet') {
|
||||
elseif ($this->table_element_line == 'contratdet') {
|
||||
$objectline = new ContratLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='commande_fournisseurdet') {
|
||||
elseif ($this->table_element_line == 'commande_fournisseurdet') {
|
||||
$objectline = new CommandeFournisseurLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facture_fourn_det') {
|
||||
elseif ($this->table_element_line == 'facture_fourn_det') {
|
||||
$objectline = new SupplierInvoiceLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet_rec') {
|
||||
elseif ($this->table_element_line == 'facturedet_rec') {
|
||||
$objectline = new FactureLigneRec($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || ! is_object($conf))
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
|
||||
@ -46,9 +46,9 @@ class ProductFournisseur extends Product
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error='';
|
||||
public $error = '';
|
||||
|
||||
public $product_fourn_price_id; // id of ligne product-supplier
|
||||
public $product_fourn_price_id; // id of ligne product-supplier
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
@ -61,18 +61,18 @@ class ProductFournisseur extends Product
|
||||
*/
|
||||
public $fourn_ref;
|
||||
public $delivery_time_days;
|
||||
public $ref_supplier; // ref supplier (can be set by get_buyprice)
|
||||
public $ref_supplier; // ref supplier (can be set by get_buyprice)
|
||||
public $desc_supplier;
|
||||
public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
|
||||
public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
|
||||
|
||||
public $fourn_id; //supplier id
|
||||
public $fourn_qty; // quantity for price (can be set by get_buyprice)
|
||||
public $fourn_pu; // unit price for quantity (can be set by get_buyprice)
|
||||
public $fourn_id; //supplier id
|
||||
public $fourn_qty; // quantity for price (can be set by get_buyprice)
|
||||
public $fourn_pu; // unit price for quantity (can be set by get_buyprice)
|
||||
|
||||
public $fourn_price; // price for quantity
|
||||
public $fourn_remise_percent; // discount for quantity (percent)
|
||||
public $fourn_remise; // discount for quantity (amount)
|
||||
public $product_fourn_id; // product-supplier id
|
||||
public $fourn_price; // price for quantity
|
||||
public $fourn_remise_percent; // discount for quantity (percent)
|
||||
public $fourn_remise; // discount for quantity (amount)
|
||||
public $product_fourn_id; // product-supplier id
|
||||
|
||||
/**
|
||||
* @var int ID user_id - user who created/updated supplier price
|
||||
@ -93,8 +93,8 @@ class ProductFournisseur extends Product
|
||||
*/
|
||||
public $fk_supplier_price_expression;
|
||||
|
||||
public $supplier_reputation; // reputation of supplier
|
||||
public $reputations=array(); // list of available supplier reputations
|
||||
public $supplier_reputation; // reputation of supplier
|
||||
public $reputations = array(); // list of available supplier reputations
|
||||
|
||||
// Multicurreny
|
||||
public $fourn_multicurrency_id;
|
||||
@ -114,7 +114,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
$this->db = $db;
|
||||
$langs->load("suppliers");
|
||||
$this->reputations= array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
|
||||
$this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
|
||||
}
|
||||
|
||||
|
||||
@ -129,19 +129,19 @@ class ProductFournisseur extends Product
|
||||
public function remove_fournisseur($id_fourn)
|
||||
{
|
||||
// phpcs:enable
|
||||
$ok=1;
|
||||
$ok = 1;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
|
||||
$sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
|
||||
|
||||
dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG);
|
||||
$resql2=$this->db->query($sql);
|
||||
if (! $resql2)
|
||||
$resql2 = $this->db->query($sql);
|
||||
if (!$resql2)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$ok=0;
|
||||
$this->error = $this->db->lasterror();
|
||||
$ok = 0;
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
@ -169,25 +169,25 @@ class ProductFournisseur extends Product
|
||||
// phpcs:enable
|
||||
global $conf, $user;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user);
|
||||
$result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -238,66 +238,66 @@ class ProductFournisseur extends Product
|
||||
//global $mysoc;
|
||||
|
||||
// Clean parameter
|
||||
if (empty($qty)) $qty=0;
|
||||
if (empty($buyprice)) $buyprice=0;
|
||||
if (empty($charges)) $charges=0;
|
||||
if (empty($availability)) $availability=0;
|
||||
if (empty($remise_percent)) $remise_percent=0;
|
||||
if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation='';
|
||||
if ($delivery_time_days != '' && ! is_numeric($delivery_time_days)) $delivery_time_days = '';
|
||||
if (empty($qty)) $qty = 0;
|
||||
if (empty($buyprice)) $buyprice = 0;
|
||||
if (empty($charges)) $charges = 0;
|
||||
if (empty($availability)) $availability = 0;
|
||||
if (empty($remise_percent)) $remise_percent = 0;
|
||||
if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = '';
|
||||
if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = '';
|
||||
if ($price_base_type == 'TTC')
|
||||
{
|
||||
$ttx = $tva_tx;
|
||||
$buyprice = $buyprice/(1+($ttx/100));
|
||||
$buyprice = $buyprice / (1 + ($ttx / 100));
|
||||
}
|
||||
|
||||
// Multicurrency
|
||||
if ($conf->multicurrency->enabled) {
|
||||
if (empty($multicurrency_tx)) $multicurrency_tx=1;
|
||||
if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0;
|
||||
if (empty($multicurrency_tx)) $multicurrency_tx = 1;
|
||||
if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
|
||||
|
||||
if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0;
|
||||
if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
|
||||
if ($multicurrency_price_base_type == 'TTC')
|
||||
{
|
||||
$ttx = $tva_tx;
|
||||
$multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100));
|
||||
$multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100));
|
||||
}
|
||||
$multicurrency_buyprice=price2num($multicurrency_buyprice, 'MU');
|
||||
$multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty, 'MU');
|
||||
$multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU');
|
||||
$multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU');
|
||||
|
||||
$buyprice=$multicurrency_buyprice/$multicurrency_tx;
|
||||
$buyprice = $multicurrency_buyprice / $multicurrency_tx;
|
||||
$fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code);
|
||||
}
|
||||
|
||||
$buyprice=price2num($buyprice, 'MU');
|
||||
$charges=price2num($charges, 'MU');
|
||||
$qty=price2num($qty, 'MS');
|
||||
$unitBuyPrice = price2num($buyprice/$qty, 'MU');
|
||||
$buyprice = price2num($buyprice, 'MU');
|
||||
$charges = price2num($charges, 'MU');
|
||||
$qty = price2num($qty, 'MS');
|
||||
$unitBuyPrice = price2num($buyprice / $qty, 'MU');
|
||||
|
||||
$error=0;
|
||||
$now=dol_now();
|
||||
$error = 0;
|
||||
$now = dol_now();
|
||||
|
||||
$newvat = $tva_tx;
|
||||
|
||||
if (count($localtaxes_array) > 0)
|
||||
{
|
||||
$localtaxtype1=$localtaxes_array['0'];
|
||||
$localtax1=$localtaxes_array['1'];
|
||||
$localtaxtype2=$localtaxes_array['2'];
|
||||
$localtax2=$localtaxes_array['3'];
|
||||
$localtaxtype1 = $localtaxes_array['0'];
|
||||
$localtax1 = $localtaxes_array['1'];
|
||||
$localtaxtype2 = $localtaxes_array['2'];
|
||||
$localtax2 = $localtaxes_array['3'];
|
||||
}
|
||||
else // old method. deprecated because ot can't retreive type
|
||||
{
|
||||
$localtaxtype1='0';
|
||||
$localtax1=get_localtax($newvat, 1);
|
||||
$localtaxtype2='0';
|
||||
$localtax2=get_localtax($newvat, 2);
|
||||
$localtaxtype1 = '0';
|
||||
$localtax1 = get_localtax($newvat, 1);
|
||||
$localtaxtype2 = '0';
|
||||
$localtax2 = get_localtax($newvat, 2);
|
||||
}
|
||||
if (empty($localtax1)) $localtax1=0; // If = '' then = 0
|
||||
if (empty($localtax2)) $localtax2=0; // If = '' then = 0
|
||||
if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0
|
||||
if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0
|
||||
|
||||
// Check parameters
|
||||
if ($buyprice != '' && ! is_numeric($buyprice))
|
||||
if ($buyprice != '' && !is_numeric($buyprice))
|
||||
{
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ class ProductFournisseur extends Product
|
||||
if (is_array($logPrices) && count($logPrices) == 0)
|
||||
{
|
||||
$currentPfp = new self($this->db);
|
||||
$result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
|
||||
$result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
|
||||
if ($result > 0 && $currentPfp->fourn_price != 0)
|
||||
{
|
||||
$currentPfpUser = new User($this->db);
|
||||
@ -331,35 +331,35 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
}
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql.= " SET fk_user = " . $user->id." ,";
|
||||
$sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',";
|
||||
$sql.= " desc_fourn = '" . $this->db->escape($desc_fourn) . "',";
|
||||
$sql.= " price = ".$buyprice.",";
|
||||
$sql.= " quantity = ".$qty.",";
|
||||
$sql.= " remise_percent = ".$remise_percent.",";
|
||||
$sql.= " remise = ".$remise.",";
|
||||
$sql.= " unitprice = ".$unitBuyPrice.",";
|
||||
$sql.= " fk_availability = ".$availability.",";
|
||||
$sql.= " multicurrency_price = ".(isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
|
||||
$sql.= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
|
||||
$sql.= " multicurrency_tx = ".(isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
|
||||
$sql.= " fk_multicurrency = ".(isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
|
||||
$sql.= " multicurrency_code = ".(isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
|
||||
$sql.= " entity = ".$conf->entity.",";
|
||||
$sql.= " tva_tx = ".price2num($tva_tx).",";
|
||||
$sql .= " SET fk_user = ".$user->id." ,";
|
||||
$sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',";
|
||||
$sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',";
|
||||
$sql .= " price = ".$buyprice.",";
|
||||
$sql .= " quantity = ".$qty.",";
|
||||
$sql .= " remise_percent = ".$remise_percent.",";
|
||||
$sql .= " remise = ".$remise.",";
|
||||
$sql .= " unitprice = ".$unitBuyPrice.",";
|
||||
$sql .= " fk_availability = ".$availability.",";
|
||||
$sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
|
||||
$sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
|
||||
$sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
|
||||
$sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
|
||||
$sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
|
||||
$sql .= " entity = ".$conf->entity.",";
|
||||
$sql .= " tva_tx = ".price2num($tva_tx).",";
|
||||
// TODO Add localtax1 and localtax2
|
||||
//$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').",";
|
||||
//$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').",";
|
||||
//$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").",";
|
||||
//$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").",";
|
||||
$sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
|
||||
$sql.= " info_bits = ".$newnpr.",";
|
||||
$sql.= " charges = ".$charges.","; // deprecated
|
||||
$sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').",";
|
||||
$sql.= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
|
||||
$sql.= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
|
||||
$sql.= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
|
||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
$sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
|
||||
$sql .= " info_bits = ".$newnpr.",";
|
||||
$sql .= " charges = ".$charges.","; // deprecated
|
||||
$sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').",";
|
||||
$sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
|
||||
$sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
|
||||
$sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
|
||||
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
// TODO Add price_base_type and price_ttc
|
||||
|
||||
dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG);
|
||||
@ -367,10 +367,10 @@ class ProductFournisseur extends Product
|
||||
if ($resql)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user);
|
||||
$result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG))
|
||||
if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG))
|
||||
{
|
||||
$result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
|
||||
if ($result < 0) {
|
||||
@ -390,7 +390,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=".$sql;
|
||||
$this->error = $this->db->error()." sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
@ -398,57 +398,57 @@ class ProductFournisseur extends Product
|
||||
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this) . '::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG);
|
||||
dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG);
|
||||
|
||||
// Delete price for this quantity
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price";
|
||||
$sql .= " WHERE fk_soc = " . $fourn->id . " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "' AND quantity = " . $qty . " AND entity = " . $conf->entity;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
// Add price for this quantity to supplier
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
|
||||
$sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
|
||||
$sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
|
||||
$sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
|
||||
$sql .= " values(";
|
||||
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
|
||||
$sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
|
||||
$sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
|
||||
$sql .= " '" . $this->db->idate($now) . "',";
|
||||
$sql .= " " . $this->id . ",";
|
||||
$sql .= " " . $fourn->id . ",";
|
||||
$sql .= " '" . $this->db->escape($ref_fourn) . "',";
|
||||
$sql .= " '" . $this->db->escape($desc_fourn) . "',";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . $buyprice . ",";
|
||||
$sql .= " " . $qty . ",";
|
||||
$sql .= " " . $remise_percent . ",";
|
||||
$sql .= " " . $remise . ",";
|
||||
$sql .= " " . $unitBuyPrice . ",";
|
||||
$sql .= " " . $tva_tx . ",";
|
||||
$sql .= " " . $charges . ",";
|
||||
$sql .= " " . $availability . ",";
|
||||
$sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
|
||||
$sql .= " " . $newnpr . ",";
|
||||
$sql .= $conf->entity . ",";
|
||||
$sql .= $delivery_time_days . ",";
|
||||
$sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'") . ",";
|
||||
$sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'") . ",";
|
||||
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'");
|
||||
$sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
|
||||
$sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
|
||||
$sql .= " '".$this->db->idate($now)."',";
|
||||
$sql .= " ".$this->id.",";
|
||||
$sql .= " ".$fourn->id.",";
|
||||
$sql .= " '".$this->db->escape($ref_fourn)."',";
|
||||
$sql .= " '".$this->db->escape($desc_fourn)."',";
|
||||
$sql .= " ".$user->id.",";
|
||||
$sql .= " ".$buyprice.",";
|
||||
$sql .= " ".$qty.",";
|
||||
$sql .= " ".$remise_percent.",";
|
||||
$sql .= " ".$remise.",";
|
||||
$sql .= " ".$unitBuyPrice.",";
|
||||
$sql .= " ".$tva_tx.",";
|
||||
$sql .= " ".$charges.",";
|
||||
$sql .= " ".$availability.",";
|
||||
$sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
|
||||
$sql .= " ".$newnpr.",";
|
||||
$sql .= $conf->entity.",";
|
||||
$sql .= $delivery_time_days.",";
|
||||
$sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
|
||||
$sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
|
||||
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
|
||||
$sql .= ")";
|
||||
|
||||
$idinserted = 0;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price");
|
||||
$idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
|
||||
}
|
||||
else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
|
||||
if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
|
||||
// Add record into log table
|
||||
$result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrenc, $multicurrency_code);
|
||||
if ($result < 0) {
|
||||
@ -456,7 +456,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user);
|
||||
if ($result < 0)
|
||||
@ -472,14 +472,14 @@ class ProductFournisseur extends Product
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror() . " sql=" . $sql;
|
||||
$this->error = $this->db->lasterror()." sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror() . " sql=" . $sql;
|
||||
$this->error = $this->db->lasterror()." sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -498,12 +498,12 @@ class ProductFournisseur extends Product
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
|
||||
$sql.= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
|
||||
$sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
|
||||
$sql.=" pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE pfp.rowid = ".$rowid;
|
||||
$sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
|
||||
$sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
|
||||
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
|
||||
$sql .= " pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql .= " WHERE pfp.rowid = ".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -512,16 +512,16 @@ class ProductFournisseur extends Product
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
$this->product_fourn_price_id = $rowid;
|
||||
$this->id = $obj->fk_product;
|
||||
$this->product_fourn_price_id = $rowid;
|
||||
$this->id = $obj->fk_product;
|
||||
$this->fk_product = $obj->fk_product;
|
||||
$this->product_id = $obj->fk_product; // deprecated
|
||||
$this->product_id = $obj->fk_product; // deprecated
|
||||
$this->fourn_id = $obj->fk_soc;
|
||||
$this->fourn_ref = $obj->ref_fourn; // deprecated
|
||||
$this->ref_supplier = $obj->ref_fourn;
|
||||
$this->desc_supplier = $obj->desc_fourn;
|
||||
$this->fourn_price = $obj->price;
|
||||
$this->fourn_charges = $obj->charges; // deprecated
|
||||
$this->fourn_price = $obj->price;
|
||||
$this->fourn_charges = $obj->charges; // deprecated
|
||||
$this->fourn_qty = $obj->quantity;
|
||||
$this->fourn_remise_percent = $obj->remise_percent;
|
||||
$this->fourn_remise = $obj->remise;
|
||||
@ -529,9 +529,9 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_tva_tx = $obj->tva_tx;
|
||||
$this->fourn_tva_npr = $obj->fourn_tva_npr;
|
||||
// Add also localtaxes
|
||||
$this->fk_availability = $obj->fk_availability;
|
||||
$this->delivery_time_days = $obj->delivery_time_days;
|
||||
$this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
|
||||
$this->fk_availability = $obj->fk_availability;
|
||||
$this->delivery_time_days = $obj->delivery_time_days;
|
||||
$this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
|
||||
$this->supplier_reputation = $obj->supplier_reputation;
|
||||
$this->default_vat_code = $obj->default_vat_code;
|
||||
$this->user_id = $obj->fk_user;
|
||||
@ -541,7 +541,7 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_multicurrency_tx = $obj->multicurrency_tx;
|
||||
$this->fourn_multicurrency_id = $obj->fk_multicurrency;
|
||||
$this->fourn_multicurrency_code = $obj->multicurrency_code;
|
||||
if($conf->barcode->enabled) {
|
||||
if ($conf->barcode->enabled) {
|
||||
$this->fourn_barcode = $obj->barcode;
|
||||
$this->fourn_fk_barcode_type = $obj->fk_barcode_type;
|
||||
}
|
||||
@ -552,13 +552,13 @@ class ProductFournisseur extends Product
|
||||
if ($price_result >= 0) {
|
||||
$this->fourn_price = $price_result;
|
||||
//recalculation of unitprice, as probably the price changed...
|
||||
if ($this->fourn_qty!=0)
|
||||
if ($this->fourn_qty != 0)
|
||||
{
|
||||
$this->fourn_unitprice = price2num($this->fourn_price/$this->fourn_qty, 'MU');
|
||||
$this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fourn_unitprice="";
|
||||
$this->fourn_unitprice = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -572,7 +572,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -595,18 +595,18 @@ class ProductFournisseur extends Product
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
|
||||
$sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
|
||||
$sql.= " pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
|
||||
$sql.= " AND pfp.fk_soc = s.rowid";
|
||||
$sql.= " AND s.status=1"; // only enabled company selected
|
||||
$sql.= " AND pfp.fk_product = ".$prodid;
|
||||
if (empty($sortfield)) $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
||||
else $sql.= $this->db->order($sortfield, $sortorder);
|
||||
$sql.=$this->db->plimit($limit, $offset);
|
||||
$sql .= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
|
||||
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
|
||||
$sql .= " pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
|
||||
$sql .= " AND pfp.fk_soc = s.rowid";
|
||||
$sql .= " AND s.status=1"; // only enabled company selected
|
||||
$sql .= " AND pfp.fk_product = ".$prodid;
|
||||
if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
||||
else $sql .= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -619,26 +619,26 @@ class ProductFournisseur extends Product
|
||||
//define base attribute
|
||||
$prodfourn = new ProductFournisseur($this->db);
|
||||
|
||||
$prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"];
|
||||
$prodfourn->product_fourn_id = $record["product_fourn_id"];
|
||||
$prodfourn->fourn_ref = $record["ref_fourn"];
|
||||
$prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"];
|
||||
$prodfourn->product_fourn_id = $record["product_fourn_id"];
|
||||
$prodfourn->fourn_ref = $record["ref_fourn"];
|
||||
$prodfourn->ref_supplier = $record["ref_fourn"];
|
||||
$prodfourn->desc_supplier = $record["desc_fourn"];
|
||||
$prodfourn->desc_supplier = $record["desc_fourn"];
|
||||
$prodfourn->fourn_price = $record["price"];
|
||||
$prodfourn->fourn_qty = $record["quantity"];
|
||||
$prodfourn->fourn_remise_percent = $record["remise_percent"];
|
||||
$prodfourn->fourn_remise = $record["remise"];
|
||||
$prodfourn->fourn_unitprice = $record["unitprice"];
|
||||
$prodfourn->fourn_charges = $record["charges"]; // deprecated
|
||||
$prodfourn->fourn_tva_tx = $record["tva_tx"];
|
||||
$prodfourn->fourn_qty = $record["quantity"];
|
||||
$prodfourn->fourn_remise_percent = $record["remise_percent"];
|
||||
$prodfourn->fourn_remise = $record["remise"];
|
||||
$prodfourn->fourn_unitprice = $record["unitprice"];
|
||||
$prodfourn->fourn_charges = $record["charges"]; // deprecated
|
||||
$prodfourn->fourn_tva_tx = $record["tva_tx"];
|
||||
$prodfourn->fourn_id = $record["fourn_id"];
|
||||
$prodfourn->fourn_name = $record["supplier_name"];
|
||||
$prodfourn->fourn_name = $record["supplier_name"];
|
||||
$prodfourn->fk_availability = $record["fk_availability"];
|
||||
$prodfourn->delivery_time_days = $record["delivery_time_days"];
|
||||
$prodfourn->id = $prodid;
|
||||
$prodfourn->fourn_tva_npr = $record["info_bits"];
|
||||
$prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
$prodfourn->supplier_reputation = $record["supplier_reputation"];
|
||||
$prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
$prodfourn->supplier_reputation = $record["supplier_reputation"];
|
||||
$prodfourn->fourn_date_creation = $this->db->jdate($record['datec']);
|
||||
$prodfourn->fourn_date_modification = $this->db->jdate($record['tms']);
|
||||
|
||||
@ -648,9 +648,9 @@ class ProductFournisseur extends Product
|
||||
$prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
|
||||
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
|
||||
|
||||
if($conf->barcode->enabled){
|
||||
$prodfourn->barcode = $record["barcode"];
|
||||
$prodfourn->fk_barcode_type = $record["fk_barcode_type"];
|
||||
if ($conf->barcode->enabled) {
|
||||
$prodfourn->barcode = $record["barcode"];
|
||||
$prodfourn->fk_barcode_type = $record["fk_barcode_type"];
|
||||
}
|
||||
|
||||
if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
|
||||
@ -664,17 +664,17 @@ class ProductFournisseur extends Product
|
||||
|
||||
if (!isset($prodfourn->fourn_unitprice))
|
||||
{
|
||||
if ($prodfourn->fourn_qty!=0)
|
||||
if ($prodfourn->fourn_qty != 0)
|
||||
{
|
||||
$prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price/$prodfourn->fourn_qty, 'MU');
|
||||
$prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
$prodfourn->fourn_unitprice="";
|
||||
$prodfourn->fourn_unitprice = "";
|
||||
}
|
||||
}
|
||||
|
||||
$retarray[]=$prodfourn;
|
||||
$retarray[] = $prodfourn;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -682,7 +682,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -717,7 +717,7 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_unitprice = '';
|
||||
$this->fourn_id = '';
|
||||
$this->fourn_name = '';
|
||||
$this->delivery_time_days = '';
|
||||
$this->delivery_time_days = '';
|
||||
$this->id = '';
|
||||
|
||||
$this->fourn_multicurrency_price = '';
|
||||
@ -727,18 +727,18 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_multicurrency_code = '';
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
|
||||
$sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
|
||||
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
$sql.= " AND pfp.entity = ".$conf->entity; // only current entity
|
||||
$sql.= " AND pfp.fk_product = ".$prodid;
|
||||
$sql.= " AND pfp.fk_soc = s.rowid";
|
||||
$sql.= " AND s.status = 1"; // only enabled society
|
||||
if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
|
||||
if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid;
|
||||
$sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
|
||||
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
|
||||
$sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
|
||||
$sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
$sql .= " AND pfp.entity = ".$conf->entity; // only current entity
|
||||
$sql .= " AND pfp.fk_product = ".$prodid;
|
||||
$sql .= " AND pfp.fk_soc = s.rowid";
|
||||
$sql .= " AND s.status = 1"; // only enabled society
|
||||
if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty;
|
||||
if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid;
|
||||
|
||||
dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG);
|
||||
|
||||
@ -750,7 +750,7 @@ class ProductFournisseur extends Product
|
||||
//Store each record to array for later search of min
|
||||
while ($record = $this->db->fetch_array($resql))
|
||||
{
|
||||
$record_array[]=$record;
|
||||
$record_array[] = $record;
|
||||
}
|
||||
|
||||
if (count($record_array) == 0)
|
||||
@ -761,7 +761,7 @@ class ProductFournisseur extends Product
|
||||
else
|
||||
{
|
||||
$min = -1;
|
||||
foreach($record_array as $record)
|
||||
foreach ($record_array as $record)
|
||||
{
|
||||
$fourn_price = $record["price"];
|
||||
// discount calculated buy price
|
||||
@ -779,7 +779,7 @@ class ProductFournisseur extends Product
|
||||
$fourn_price = price2num($price_result, 'MU');
|
||||
if ($record["quantity"] != 0)
|
||||
{
|
||||
$fourn_unitprice = price2num($fourn_price/$record["quantity"], 'MU');
|
||||
$fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -791,19 +791,19 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
$this->product_fourn_price_id = $record["product_fourn_price_id"];
|
||||
$this->ref_supplier = $record["ref_fourn"];
|
||||
$this->ref_fourn = $record["ref_fourn"]; // deprecated
|
||||
$this->fourn_ref = $record["ref_fourn"]; // deprecated
|
||||
$this->ref_fourn = $record["ref_fourn"]; // deprecated
|
||||
$this->fourn_ref = $record["ref_fourn"]; // deprecated
|
||||
$this->fourn_price = $fourn_price;
|
||||
$this->fourn_qty = $record["quantity"];
|
||||
$this->fourn_remise_percent = $record["remise_percent"];
|
||||
$this->fourn_remise = $record["remise"];
|
||||
$this->fourn_unitprice = $record["unitprice"];
|
||||
$this->fourn_charges = $record["charges"]; // deprecated
|
||||
$this->fourn_charges = $record["charges"]; // deprecated
|
||||
$this->fourn_tva_tx = $record["tva_tx"];
|
||||
$this->fourn_id = $record["fourn_id"];
|
||||
$this->fourn_name = $record["supplier_name"];
|
||||
$this->delivery_time_days = $record["delivery_time_days"];
|
||||
$this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
$this->delivery_time_days = $record["delivery_time_days"];
|
||||
$this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
$this->id = $prodid;
|
||||
$this->fourn_multicurrency_price = $record["multicurrency_price"];
|
||||
$this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
|
||||
@ -820,7 +820,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -840,8 +840,8 @@ class ProductFournisseur extends Product
|
||||
$expression_id = $expression_id != 0 ? $expression_id : 'NULL';
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql.= " SET fk_supplier_price_expression = ".$expression_id;
|
||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
$sql .= " SET fk_supplier_price_expression = ".$expression_id;
|
||||
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
|
||||
dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG);
|
||||
|
||||
@ -853,7 +853,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=".$sql;
|
||||
$this->error = $this->db->error()." sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -898,19 +898,19 @@ class ProductFournisseur extends Product
|
||||
$langs->load("suppliers");
|
||||
if (count($productFournList) > 0) {
|
||||
$out .= '<table class="nobordernopadding" width="100%">';
|
||||
$out .= '<tr><td class="liste_titre right">'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').'</td>';
|
||||
$out .= '<td class="liste_titre right">'.($showunitprice?$langs->trans("QtyMin"):'').'</td>';
|
||||
$out .= '<tr><td class="liste_titre right">'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').'</td>';
|
||||
$out .= '<td class="liste_titre right">'.($showunitprice ? $langs->trans("QtyMin") : '').'</td>';
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("Supplier").'</td>';
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td></tr>';
|
||||
foreach ($productFournList as $productFourn) {
|
||||
$out.= '<tr><td class="right">'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').'</td>';
|
||||
$out.= '<td class="right">'.($showunitprice?$productFourn->fourn_qty:'').'</td>';
|
||||
$out.= '<td>'.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).'</td>';
|
||||
$out.= '<td>'.$productFourn->fourn_ref.'<td></tr>';
|
||||
$out .= '<tr><td class="right">'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').'</td>';
|
||||
$out .= '<td class="right">'.($showunitprice ? $productFourn->fourn_qty : '').'</td>';
|
||||
$out .= '<td>'.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).'</td>';
|
||||
$out .= '<td>'.$productFourn->fourn_ref.'<td></tr>';
|
||||
}
|
||||
$out .= '</table>';
|
||||
} else {
|
||||
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").' (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
|
||||
$out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : '');
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@ -947,18 +947,18 @@ class ProductFournisseur extends Product
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
|
||||
$sql.= " pfpl.price, pfpl.quantity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
|
||||
$sql.= " AND pfpl.fk_user = u.rowid";
|
||||
$sql.= " AND pfp.rowid = pfpl.fk_product_fournisseur";
|
||||
$sql.= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id;
|
||||
if (empty($sortfield)) $sql.= " ORDER BY pfpl.datec";
|
||||
else $sql.= $this->db->order($sortfield, $sortorder);
|
||||
$sql.=$this->db->plimit($limit, $offset);
|
||||
$sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
|
||||
$sql .= " pfpl.price, pfpl.quantity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE pfp.entity IN (".getEntity('productprice').")";
|
||||
$sql .= " AND pfpl.fk_user = u.rowid";
|
||||
$sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur";
|
||||
$sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id;
|
||||
if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec";
|
||||
else $sql .= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -968,7 +968,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
while ($record = $this->db->fetch_array($resql))
|
||||
{
|
||||
$retarray[]=$record;
|
||||
$retarray[] = $record;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -976,7 +976,7 @@ class ProductFournisseur extends Product
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1001,10 +1001,10 @@ class ProductFournisseur extends Product
|
||||
//$out .= '<td class="liste_titre right">'.$langs->trans("QtyMin").'</td>';
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("User").'</td></tr>';
|
||||
foreach ($productFournLogList as $productFournLog) {
|
||||
$out.= '<tr><td class="right">'.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').'</td>';
|
||||
$out.= '<td class="right">'.price($productFournLog['price']).'</td>';
|
||||
$out .= '<tr><td class="right">'.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').'</td>';
|
||||
$out .= '<td class="right">'.price($productFournLog['price']).'</td>';
|
||||
//$out.= '<td class="right">'.$productFournLog['quantity'].'</td>';
|
||||
$out.= '<td>'.$productFournLog['lastname'].'</td></tr>';
|
||||
$out .= '<td>'.$productFournLog['lastname'].'</td></tr>';
|
||||
}
|
||||
$out .= '</table>';
|
||||
}
|
||||
@ -1027,19 +1027,19 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
global $db, $conf, $langs;
|
||||
|
||||
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
||||
|
||||
$result = '';
|
||||
|
||||
$label = '<u>' . $langs->trans("SupplierRef") . '</u>';
|
||||
$label.= '<br>';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref_supplier;
|
||||
$label = '<u>'.$langs->trans("SupplierRef").'</u>';
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref_supplier;
|
||||
|
||||
$logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
|
||||
if (is_array($logPrices) && count($logPrices) > 0) {
|
||||
$label.= '<br>';
|
||||
$label.= '<u>' . $langs->trans("History") . '</u>';
|
||||
$label.= $this->displayPriceProductFournisseurLog($logPrices);
|
||||
$label .= '<br>';
|
||||
$label .= '<u>'.$langs->trans("History").'</u>';
|
||||
$label .= $this->displayPriceProductFournisseurLog($logPrices);
|
||||
}
|
||||
|
||||
$url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id;
|
||||
@ -1047,31 +1047,31 @@ class ProductFournisseur extends Product
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkclose='';
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("SupplierRef");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
$label = $langs->trans("SupplierRef");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
}
|
||||
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
|
||||
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
$linkstart .= $linkclose.'>';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
|
||||
if ($withpicto != 2) $result.= $this->fourn_ref;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->fourn_ref;
|
||||
$result .= $linkend;
|
||||
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
|
||||
|
||||
@ -1096,24 +1096,24 @@ class ProductFournisseur extends Product
|
||||
private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null)
|
||||
{
|
||||
// Add record into log table
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log(";
|
||||
$sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log(";
|
||||
$sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
|
||||
$sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)";
|
||||
$sql .= "values(";
|
||||
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
|
||||
$sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
|
||||
$sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
|
||||
$sql .= "'" . $this->db->idate($datec) . "',";
|
||||
$sql .= " " . $this->product_fourn_price_id . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . price2num($buyprice) . ",";
|
||||
$sql .= " " . $qty;
|
||||
$sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
|
||||
$sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
|
||||
$sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
|
||||
$sql .= "'".$this->db->idate($datec)."',";
|
||||
$sql .= " ".$this->product_fourn_price_id.",";
|
||||
$sql .= " ".$user->id.",";
|
||||
$sql .= " ".price2num($buyprice).",";
|
||||
$sql .= " ".$qty;
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
if (!$resql) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
|
||||
@ -40,9 +40,9 @@ $result = restrictedArea($user, 'societe', $socid, '');
|
||||
* View
|
||||
*/
|
||||
|
||||
$commandestatic=new CommandeFournisseur($db);
|
||||
$facturestatic=new FactureFournisseur($db);
|
||||
$companystatic=new Societe($db);
|
||||
$commandestatic = new CommandeFournisseur($db);
|
||||
$facturestatic = new FactureFournisseur($db);
|
||||
$companystatic = new Societe($db);
|
||||
|
||||
llxHeader("", $langs->trans("SuppliersArea"));
|
||||
|
||||
@ -56,13 +56,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
// Orders
|
||||
$sql = "SELECT count(cf.rowid), cf.fk_statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
$sql.= " WHERE cf.fk_soc = s.rowid ";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
|
||||
$sql.= " AND cf.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY cf.fk_statut";
|
||||
$sql .= " WHERE cf.fk_soc = s.rowid ";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
|
||||
$sql .= " AND cf.entity = ".$conf->entity;
|
||||
$sql .= " GROUP BY cf.fk_statut";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -97,19 +97,19 @@ else
|
||||
|
||||
|
||||
// Draft orders
|
||||
if (! empty($conf->fournisseur->enabled))
|
||||
if (!empty($conf->fournisseur->enabled))
|
||||
{
|
||||
$langs->load("orders");
|
||||
|
||||
$sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,";
|
||||
$sql.= " s.nom as name, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " s.nom as name, s.rowid as socid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
$sql.= " WHERE cf.fk_soc = s.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
|
||||
$sql.= " AND cf.entity = ".$conf->entity;
|
||||
$sql.= " AND cf.fk_statut = 0";
|
||||
$sql .= " WHERE cf.fk_soc = s.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
|
||||
$sql .= " AND cf.entity = ".$conf->entity;
|
||||
$sql .= " AND cf.fk_statut = 0";
|
||||
if ($socid) $sql .= " AND cf.fk_soc = ".$socid;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -129,21 +129,21 @@ if (! empty($conf->fournisseur->enabled))
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
$commandestatic->id=$obj->rowid;
|
||||
$commandestatic->ref=$obj->ref;
|
||||
$commandestatic->id = $obj->rowid;
|
||||
$commandestatic->ref = $obj->ref;
|
||||
print $commandestatic->getNomUrl(1, '', 16);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">';
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->client=0;
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->name;
|
||||
$companystatic->client = 0;
|
||||
print $companystatic->getNomUrl(1, '', 16);
|
||||
print '</td>';
|
||||
print '<td class="right nowrap">'.price($obj->total_ttc).'</td></tr>';
|
||||
$i++;
|
||||
$total += $obj->total_ttc;
|
||||
}
|
||||
if ($total>0)
|
||||
if ($total > 0)
|
||||
{
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
|
||||
}
|
||||
@ -154,22 +154,22 @@ if (! empty($conf->fournisseur->enabled))
|
||||
}
|
||||
|
||||
// Draft invoices
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
|
||||
$sql.= ", s.nom as name, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", s.nom as name, s.rowid as socid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
$sql.= " WHERE s.rowid = ff.fk_soc";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id;
|
||||
$sql.= " AND ff.entity = ".$conf->entity;
|
||||
$sql.= " AND ff.fk_statut = 0";
|
||||
$sql .= " WHERE s.rowid = ff.fk_soc";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
|
||||
$sql .= " AND ff.entity = ".$conf->entity;
|
||||
$sql .= " AND ff.fk_statut = 0";
|
||||
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ( $resql )
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
@ -185,20 +185,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven"><td class="nowrap">';
|
||||
$facturestatic->ref=$obj->ref;
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$facturestatic->type=$obj->type;
|
||||
$facturestatic->ref = $obj->ref;
|
||||
$facturestatic->id = $obj->rowid;
|
||||
$facturestatic->type = $obj->type;
|
||||
print $facturestatic->getNomUrl(1, '');
|
||||
print '</td>';
|
||||
print '<td class="nowrap">';
|
||||
$companystatic->id=$obj->socid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->client=0;
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->name;
|
||||
$companystatic->client = 0;
|
||||
print $companystatic->getNomUrl(1, '', 16);
|
||||
print '</td>';
|
||||
print '<td class="right">'.price($obj->total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
$tot_ttc+=$obj->total_ttc;
|
||||
$tot_ttc += $obj->total_ttc;
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -225,18 +225,18 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
/*
|
||||
* List last modified supliers
|
||||
*/
|
||||
$max=10;
|
||||
$max = 10;
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql.= ", st.libelle as stcomm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql .= ", st.libelle as stcomm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||
$sql.= " AND s.fournisseur = 1";
|
||||
$sql.= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " WHERE s.fk_stcomm = st.id";
|
||||
$sql .= " AND s.fournisseur = 1";
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY s.tms DESC";
|
||||
$sql .= " ORDER BY s.tms DESC";
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -252,7 +252,7 @@ if ($resql)
|
||||
print '<td class="right">'.$langs->trans("DateModification")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
while ($obj = $db->fetch_object($resql) )
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"), "company").'</a>';
|
||||
@ -275,7 +275,7 @@ else
|
||||
* List of suppliers categories
|
||||
*/
|
||||
$companystatic->LoadSupplierCateg();
|
||||
$categstatic=new Categorie($db);
|
||||
$categstatic = new Categorie($db);
|
||||
|
||||
if (count($companystatic->SupplierCategories))
|
||||
{
|
||||
@ -290,9 +290,9 @@ if (count($companystatic->SupplierCategories))
|
||||
{
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>';
|
||||
$categstatic->id=$rowid;
|
||||
$categstatic->ref=$label;
|
||||
$categstatic->label=$label;
|
||||
$categstatic->id = $rowid;
|
||||
$categstatic->ref = $label;
|
||||
$categstatic->label = $label;
|
||||
print $categstatic->getNomUrl(1);
|
||||
print '</td>'."\n";
|
||||
// TODO this page not exist
|
||||
|
||||
@ -911,7 +911,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
|
||||
|
||||
// Si il y a une erreur
|
||||
if (GETPOST('error')) {
|
||||
switch(GETPOST('error')) {
|
||||
switch (GETPOST('error')) {
|
||||
case 'datefin' :
|
||||
$errors[] = $langs->trans('ErrorEndDateCP');
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -22,42 +22,42 @@
|
||||
* \brief File to return datables output
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
|
||||
require '../main.inc.php';
|
||||
require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php';
|
||||
|
||||
$mens=GETPOST('mens');
|
||||
$capital=GETPOST('capital');
|
||||
$rate=GETPOST('rate');
|
||||
$echance=GETPOST('echeance');
|
||||
$nbterm=GETPOST('nbterm');
|
||||
$mens = GETPOST('mens');
|
||||
$capital = GETPOST('capital');
|
||||
$rate = GETPOST('rate');
|
||||
$echance = GETPOST('echeance');
|
||||
$nbterm = GETPOST('nbterm');
|
||||
|
||||
top_httphead();
|
||||
|
||||
$output=array();
|
||||
$output = array();
|
||||
|
||||
$object = new LoanSchedule($db);
|
||||
|
||||
$int = ($capital*($rate/12));
|
||||
$int = ($capital * ($rate / 12));
|
||||
$int = round($int, 2, PHP_ROUND_HALF_UP);
|
||||
$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP);
|
||||
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens);
|
||||
$cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP);
|
||||
$output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens);
|
||||
|
||||
$echance++;
|
||||
$capital=$cap_rest;
|
||||
while ($echance<=$nbterm) {
|
||||
$mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm-$echance+1), 2, PHP_ROUND_HALF_UP);
|
||||
$capital = $cap_rest;
|
||||
while ($echance <= $nbterm) {
|
||||
$mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP);
|
||||
|
||||
$int = ($capital*($rate/12));
|
||||
$int = ($capital * ($rate / 12));
|
||||
$int = round($int, 2, PHP_ROUND_HALF_UP);
|
||||
$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP);
|
||||
$cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP);
|
||||
|
||||
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens);
|
||||
$output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens);
|
||||
|
||||
$capital=$cap_rest;
|
||||
$capital = $cap_rest;
|
||||
$echance++;
|
||||
}
|
||||
|
||||
|
||||
@ -40,19 +40,19 @@ if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (isset($_SESSION["nbrecases"])) {
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
|
||||
if (isset($_POST["choix"][$i])) {
|
||||
$_SESSION["choix$i"]=$_POST["choix"][$i];
|
||||
$_SESSION["choix$i"] = $_POST["choix"][$i];
|
||||
}
|
||||
if (isset($_POST["typecolonne"][$i])) {
|
||||
$_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i];
|
||||
$_SESSION["typecolonne$i"] = $_POST["typecolonne"][$i];
|
||||
}
|
||||
}
|
||||
} else { //nombre de cases par défaut
|
||||
$_SESSION["nbrecases"]=5;
|
||||
$_SESSION["nbrecases"] = 5;
|
||||
}
|
||||
|
||||
if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x"))
|
||||
{
|
||||
$_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5;
|
||||
$_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5;
|
||||
}
|
||||
|
||||
// Create survey into database
|
||||
@ -62,23 +62,23 @@ if (isset($_POST["confirmecreation"]))
|
||||
$toutchoix = '';
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++)
|
||||
{
|
||||
if (! empty($_POST["choix"][$i]))
|
||||
if (!empty($_POST["choix"][$i]))
|
||||
{
|
||||
$toutchoix.=',';
|
||||
$toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]);
|
||||
$toutchoix .= ',';
|
||||
$toutchoix .= str_replace(array(",", "@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i]) ? '' : '@'.$_POST["typecolonne"][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$toutchoix=substr("$toutchoix", 1);
|
||||
$_SESSION["toutchoix"]=$toutchoix;
|
||||
$toutchoix = substr("$toutchoix", 1);
|
||||
$_SESSION["toutchoix"] = $toutchoix;
|
||||
|
||||
//test de remplissage des cases
|
||||
$testremplissage = '';
|
||||
for ($i=0;$i<$_SESSION["nbrecases"];$i++)
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++)
|
||||
{
|
||||
if (isset($_POST["choix"][$i]))
|
||||
{
|
||||
$testremplissage="ok";
|
||||
$testremplissage = "ok";
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ if (isset($_POST["confirmecreation"]))
|
||||
setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors');
|
||||
} else {
|
||||
//format du sondage AUTRE
|
||||
$_SESSION["formatsondage"]="A";
|
||||
$_SESSION["formatsondage"] = "A";
|
||||
|
||||
// Add into database
|
||||
ajouter_sondage();
|
||||
@ -101,10 +101,10 @@ if (isset($_POST["confirmecreation"]))
|
||||
* View
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$arrayofjs=array();
|
||||
$arrayofcss=array('/opensurvey/css/style.css');
|
||||
$arrayofjs = array();
|
||||
$arrayofcss = array('/opensurvey/css/style.css');
|
||||
llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss);
|
||||
|
||||
if (empty($_SESSION['titre']))
|
||||
@ -123,7 +123,7 @@ print '<form name="formulaire" action="#bas" method="POST">'."\n";
|
||||
print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)');
|
||||
|
||||
|
||||
print '<br>'. $langs->trans("PollOnChoice") .'<br><br>'."\n";
|
||||
print '<br>'.$langs->trans("PollOnChoice").'<br><br>'."\n";
|
||||
|
||||
print '<div class=corps>'."\n";
|
||||
print '<table>'."\n";
|
||||
@ -134,8 +134,8 @@ for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
|
||||
if (isset($_SESSION["choix$i"]) === false) {
|
||||
$_SESSION["choix$i"] = '';
|
||||
}
|
||||
print '<tr><td>'. $langs->trans("TitleChoice") .' '.$j.': </td><td><input type="text" name="choix[]" size="40" maxlength="40" value="'.dol_escape_htmltag($_SESSION["choix$i"]).'" id="choix'.$i.'">';
|
||||
$tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList"));
|
||||
print '<tr><td>'.$langs->trans("TitleChoice").' '.$j.': </td><td><input type="text" name="choix[]" size="40" maxlength="40" value="'.dol_escape_htmltag($_SESSION["choix$i"]).'" id="choix'.$i.'">';
|
||||
$tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList"));
|
||||
print ' '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
@ -144,7 +144,7 @@ print '</table>'."\n";
|
||||
|
||||
//ajout de cases supplementaires
|
||||
print '<table><tr>'."\n";
|
||||
print '<td>'. $langs->trans("5MoreChoices") .'</td><td><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'."\n";
|
||||
print '<td>'.$langs->trans("5MoreChoices").'</td><td><input type="image" name="ajoutcases" src="../img/add-16.png"></td>'."\n";
|
||||
print '</tr></table>'."\n";
|
||||
print'<br>'."\n";
|
||||
|
||||
|
||||
@ -22,13 +22,13 @@
|
||||
* \brief File to return Ajax response on product list request
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
@ -57,9 +57,9 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int');
|
||||
dol_syslog(join(',', $_GET));
|
||||
// print_r($_GET);
|
||||
|
||||
if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
$outjson = array();
|
||||
|
||||
@ -77,11 +77,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
$found = false;
|
||||
|
||||
// Price by qty
|
||||
if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty
|
||||
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty
|
||||
{
|
||||
$sql = "SELECT price, unitprice, quantity, remise_percent";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty ";
|
||||
$sql .= " WHERE rowid=" . $price_by_qty_rowid . "";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty ";
|
||||
$sql .= " WHERE rowid=".$price_by_qty_rowid."";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
@ -99,14 +99,14 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
}
|
||||
|
||||
// Multiprice
|
||||
if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price
|
||||
if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price
|
||||
// level (from 1 to 6)
|
||||
{
|
||||
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price ";
|
||||
$sql .= " WHERE fk_product='" . $id . "'";
|
||||
$sql .= " AND entity IN (" . getEntity('productprice') . ")";
|
||||
$sql .= " AND price_level=" . $price_level;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
$sql .= " WHERE fk_product='".$id."'";
|
||||
$sql .= " AND entity IN (".getEntity('productprice').")";
|
||||
$sql .= " AND price_level=".$price_level;
|
||||
$sql .= " ORDER BY date_price";
|
||||
$sql .= " DESC LIMIT 1";
|
||||
|
||||
@ -124,12 +124,12 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
}
|
||||
|
||||
// Price by customer
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid);
|
||||
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
@ -143,21 +143,21 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
}
|
||||
}
|
||||
|
||||
if (! $found) {
|
||||
if (!$found) {
|
||||
$outprice_ht = price($object->price);
|
||||
$outprice_ttc = price($object->price_ttc);
|
||||
$outpricebasetype = $object->price_base_type;
|
||||
$outtva_tx = $object->tva_tx;
|
||||
}
|
||||
|
||||
$outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount);
|
||||
$outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount);
|
||||
}
|
||||
|
||||
echo json_encode($outjson);
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("main");
|
||||
@ -170,19 +170,19 @@ else
|
||||
return;
|
||||
}
|
||||
|
||||
$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
|
||||
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
|
||||
sort($match);
|
||||
|
||||
$idprod = (! empty($match[0]) ? $match[0] : '');
|
||||
$idprod = (!empty($match[0]) ? $match[0] : '');
|
||||
|
||||
if (GETPOST($htmlname, 'alpha') == '' && (! $idprod || ! GETPOST($idprod, 'alpha')))
|
||||
if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha')))
|
||||
{
|
||||
print json_encode(array());
|
||||
return;
|
||||
}
|
||||
|
||||
// When used from jQuery, the search term is added as GET param "term".
|
||||
$searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : ''));
|
||||
$searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : ''));
|
||||
|
||||
$form = new Form($db);
|
||||
if (empty($mode) || $mode == 1) { // mode=1: customer
|
||||
|
||||
@ -16,16 +16,16 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || ! is_object($conf))
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
$object = $GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
@ -35,7 +35,7 @@ print load_fiche_titre($langs->trans("NewProduct"), '', 'products');
|
||||
dol_fiche_head('');
|
||||
?>
|
||||
|
||||
<?php dol_htmloutput_errors((is_numeric($object->error)?'':$object->error), $object->errors); ?>
|
||||
<?php dol_htmloutput_errors((is_numeric($object->error) ? '' : $object->error), $object->errors); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($GLOBALS['mesg'], $GLOBALS['mesgs']); ?>
|
||||
|
||||
@ -71,7 +71,7 @@ dol_fiche_head('');
|
||||
<td><?php echo $form->selectarray('statut_buy', $statutarray, $object->status_buy); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (! empty($conf->stock->enabled)) { ?>
|
||||
<?php if (!empty($conf->stock->enabled)) { ?>
|
||||
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
|
||||
<input name="seuil_stock_alerte" size="4" value="<?php echo $object->seuil_stock_alerte; ?>">
|
||||
</td></tr>
|
||||
@ -108,7 +108,7 @@ dol_fiche_head('');
|
||||
|
||||
<br>
|
||||
|
||||
<?php if (! $conf->global->PRODUIT_MULTIPRICES) { ?>
|
||||
<?php if (!$conf->global->PRODUIT_MULTIPRICES) { ?>
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
|
||||
|
||||
@ -16,16 +16,16 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || ! is_object($conf))
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
$object = $GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE CREATE.TPL -->
|
||||
@ -80,7 +80,7 @@ dol_fiche_head('');
|
||||
|
||||
<br>
|
||||
|
||||
<?php if (! $conf->global->PRODUIT_MULTIPRICES) { ?>
|
||||
<?php if (!$conf->global->PRODUIT_MULTIPRICES) { ?>
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
* \ingroup produit
|
||||
* \brief File of class to manage predefined price products or services by customer
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
/**
|
||||
* File of class to manage predefined price products or services by customer
|
||||
@ -73,7 +73,7 @@ class Productcustomerprice extends CommonObject
|
||||
*/
|
||||
public $fk_user;
|
||||
|
||||
public $lines = array ();
|
||||
public $lines = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -166,7 +166,7 @@ class Productcustomerprice extends CommonObject
|
||||
}
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price(";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price(";
|
||||
$sql .= "entity,";
|
||||
$sql .= "datec,";
|
||||
$sql .= "fk_product,";
|
||||
@ -186,39 +186,39 @@ class Productcustomerprice extends CommonObject
|
||||
$sql .= "fk_user,";
|
||||
$sql .= "import_key";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= " " . $conf->entity . ",";
|
||||
$sql .= " '" . $this->db->idate(dol_now()) . "',";
|
||||
$sql .= " " . (! isset($this->fk_product) ? 'NULL' : "'" . $this->db->escape($this->fk_product) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->fk_soc) ? 'NULL' : "'" . $this->db->escape($this->fk_soc) . "'") . ",";
|
||||
$sql .= " " . (empty($this->price) ? '0' : "'" . $this->db->escape($this->price) . "'") . ",";
|
||||
$sql .= " " . (empty($this->price_ttc) ? '0' : "'" . $this->db->escape($this->price_ttc) . "'") . ",";
|
||||
$sql .= " " . (empty($this->price_min) ? '0' : "'" . $this->db->escape($this->price_min) . "'") . ",";
|
||||
$sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->db->escape($this->price_min_ttc) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ",";
|
||||
$sql .= " ".$conf->entity.",";
|
||||
$sql .= " '".$this->db->idate(dol_now())."',";
|
||||
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").",";
|
||||
$sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").",";
|
||||
$sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").",";
|
||||
$sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").",";
|
||||
$sql .= " ".(empty($this->price_min_ttc) ? '0' : "'".$this->db->escape($this->price_min_ttc)."'").",";
|
||||
$sql .= " ".(!isset($this->price_base_type) ? 'NULL' : "'".$this->db->escape($this->price_base_type)."'").",";
|
||||
$sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").",";
|
||||
$sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ",";
|
||||
$sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->db->escape($this->recuperableonly) . "'") . ",";
|
||||
$sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->db->escape($this->localtax1_type) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ",";
|
||||
$sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->db->escape($this->localtax2_type) . "'") . ",";
|
||||
$sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . "";
|
||||
$sql .= " ".(!isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).",";
|
||||
$sql .= " ".(!isset($this->recuperableonly) ? 'NULL' : "'".$this->db->escape($this->recuperableonly)."'").",";
|
||||
$sql .= " ".(empty($this->localtax1_type) ? "'0'" : "'".$this->db->escape($this->localtax1_type)."'").",";
|
||||
$sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).",";
|
||||
$sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").",";
|
||||
$sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).",";
|
||||
$sql .= " ".$user->id.",";
|
||||
$sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'")."";
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this) . "::create", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors [] = "Error " . $this->db->lasterror();
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors [] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_customer_price");
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price");
|
||||
|
||||
if (! $notrigger) {
|
||||
if (!$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
@ -231,21 +231,21 @@ class Productcustomerprice extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
$result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
return -1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
@ -283,10 +283,10 @@ class Productcustomerprice extends CommonObject
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.import_key";
|
||||
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t";
|
||||
$sql .= " WHERE t.rowid = " . $id;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t";
|
||||
$sql .= " WHERE t.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
@ -316,8 +316,8 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
return - 1;
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,8 +337,8 @@ class Productcustomerprice extends CommonObject
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if ( empty($sortfield)) $sortfield = "t.rowid";
|
||||
if ( empty($sortorder)) $sortorder = "DESC";
|
||||
if (empty($sortfield)) $sortfield = "t.rowid";
|
||||
if (empty($sortorder)) $sortorder = "DESC";
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql .= " t.rowid,";
|
||||
@ -364,39 +364,39 @@ class Productcustomerprice extends CommonObject
|
||||
$sql .= " t.import_key,";
|
||||
$sql .= " soc.nom as socname,";
|
||||
$sql .= " prod.ref as prodref";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t ";
|
||||
$sql .= " ," . MAIN_DB_PREFIX . "product as prod ";
|
||||
$sql .= " ," . MAIN_DB_PREFIX . "societe as soc ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t ";
|
||||
$sql .= " ,".MAIN_DB_PREFIX."product as prod ";
|
||||
$sql .= " ,".MAIN_DB_PREFIX."societe as soc ";
|
||||
$sql .= " WHERE soc.rowid=t.fk_soc ";
|
||||
$sql .= " AND prod.rowid=t.fk_product ";
|
||||
$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
|
||||
$sql .= " AND t.entity IN (" . getEntity('productprice') . ")";
|
||||
$sql .= " AND prod.entity IN (".getEntity('product').")";
|
||||
$sql .= " AND t.entity IN (".getEntity('productprice').")";
|
||||
|
||||
// Manage filter
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year
|
||||
{
|
||||
$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
|
||||
$sql .= ' AND '.$key.' = \''.$value.'\'';
|
||||
} elseif ($key == 'soc.nom') {
|
||||
$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
|
||||
$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
|
||||
} elseif ($key == 'prod.ref') {
|
||||
$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
|
||||
$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
|
||||
} else {
|
||||
$sql .= ' AND ' . $key . ' = ' . $value;
|
||||
$sql .= ' AND '.$key.' = '.$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->lines = array ();
|
||||
$this->lines = array();
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$line = new PriceByCustomerLine();
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
@ -429,8 +429,8 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
return $num;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
return - 1;
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,8 +450,8 @@ class Productcustomerprice extends CommonObject
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if (! empty($sortfield)) $sortfield = "t.rowid";
|
||||
if (! empty($sortorder)) $sortorder = "DESC";
|
||||
if (!empty($sortfield)) $sortfield = "t.rowid";
|
||||
if (!empty($sortorder)) $sortorder = "DESC";
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql .= " t.rowid,";
|
||||
@ -474,38 +474,38 @@ class Productcustomerprice extends CommonObject
|
||||
$sql .= " t.import_key,";
|
||||
$sql .= " soc.nom as socname,";
|
||||
$sql .= " prod.ref as prodref";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price_log as t ";
|
||||
$sql .= " ," . MAIN_DB_PREFIX . "product as prod ";
|
||||
$sql .= " ," . MAIN_DB_PREFIX . "societe as soc ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_log as t ";
|
||||
$sql .= " ,".MAIN_DB_PREFIX."product as prod ";
|
||||
$sql .= " ,".MAIN_DB_PREFIX."societe as soc ";
|
||||
$sql .= " WHERE soc.rowid=t.fk_soc ";
|
||||
$sql .= " AND prod.rowid=t.fk_product ";
|
||||
$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
|
||||
$sql .= " AND t.entity IN (" . getEntity('productprice') . ")";
|
||||
$sql .= " AND prod.entity IN (".getEntity('product').")";
|
||||
$sql .= " AND t.entity IN (".getEntity('productprice').")";
|
||||
|
||||
// Manage filter
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year
|
||||
{
|
||||
$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
|
||||
$sql .= ' AND '.$key.' = \''.$value.'\'';
|
||||
} elseif ($key == 'soc.nom') {
|
||||
$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
|
||||
$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
|
||||
} else {
|
||||
$sql .= ' AND ' . $key . ' = ' . $value;
|
||||
$sql .= ' AND '.$key.' = '.$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->lines = array ();
|
||||
$this->lines = array();
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$line = new PriceByCustomerLine();
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
@ -536,8 +536,8 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
return $num;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
return - 1;
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
// Do a copy of current record into log table
|
||||
// Insert request
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log(";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price_log(";
|
||||
|
||||
$sql .= "entity,";
|
||||
$sql .= "datec,";
|
||||
@ -665,75 +665,75 @@ class Productcustomerprice extends CommonObject
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.import_key";
|
||||
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t";
|
||||
$sql .= " WHERE t.rowid = " . $this->id;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t";
|
||||
$sql .= " WHERE t.rowid = ".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
dol_syslog(get_class($this) . "::update", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors [] = "Error " . $this->db->lasterror();
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors [] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_customer_price SET";
|
||||
|
||||
$sql .= " entity=" . $conf->entity . ",";
|
||||
$sql .= " datec='" . $this->db->idate(dol_now()) . "',";
|
||||
$sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ",";
|
||||
$sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ",";
|
||||
$sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ",";
|
||||
$sql .= " price=" . (isset($this->price) ? $this->price : "null") . ",";
|
||||
$sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ",";
|
||||
$sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ",";
|
||||
$sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ",";
|
||||
$sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ",";
|
||||
$sql .= " entity=".$conf->entity.",";
|
||||
$sql .= " datec='".$this->db->idate(dol_now())."',";
|
||||
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
|
||||
$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
|
||||
$sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").",";
|
||||
$sql .= " price=".(isset($this->price) ? $this->price : "null").",";
|
||||
$sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").",";
|
||||
$sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").",";
|
||||
$sql .= " price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc : "null").",";
|
||||
$sql .= " price_base_type=".(isset($this->price_base_type) ? "'".$this->db->escape($this->price_base_type)."'" : "null").",";
|
||||
$sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").",";
|
||||
$sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ",";
|
||||
$sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ",";
|
||||
$sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ",";
|
||||
$sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ",";
|
||||
$sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'": "'0'") . ",";
|
||||
$sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'": "'0'") . ",";
|
||||
$sql .= " fk_user=" . $user->id . ",";
|
||||
$sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . "";
|
||||
$sql .= " tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) : "null").",";
|
||||
$sql .= " recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly : "null").",";
|
||||
$sql .= " localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) : "null").",";
|
||||
$sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").",";
|
||||
$sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").",";
|
||||
$sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").",";
|
||||
$sql .= " fk_user=".$user->id.",";
|
||||
$sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null")."";
|
||||
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::update", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors [] = "Error " . $this->db->lasterror();
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors [] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (! $notrigger) {
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
|
||||
$interface = new Interfaces($this->db);
|
||||
$result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf);
|
||||
if ($result < 0) { $error++; $this->errors = $interface->errors; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
$result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
return -1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
@ -754,34 +754,34 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
// Find all susidiaries
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
||||
$sql .= " WHERE s.parent = " . $this->fk_soc;
|
||||
$sql .= " AND s.entity IN (" . getEntity('societe') . ")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.parent = ".$this->fk_soc;
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
|
||||
dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
$this->lines = array ();
|
||||
$this->lines = array();
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) {
|
||||
while (($obj = $this->db->fetch_object($resql)) && (empty($error))) {
|
||||
// find if there is an existing line for the product and the subsidiaries
|
||||
$prodsocprice = new Productcustomerprice($this->db);
|
||||
|
||||
$filter = array (
|
||||
't.fk_product' => $this->fk_product,'t.fk_soc' => $obj->rowid
|
||||
$filter = array(
|
||||
't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid
|
||||
);
|
||||
|
||||
$result = $prodsocprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
$this->error = $prodsocprice->error;
|
||||
} else {
|
||||
// There is one line
|
||||
if (count($prodsocprice->lines) > 0) {
|
||||
// If force update => Update
|
||||
if (! empty($forceupdateaffiliate)) {
|
||||
if (!empty($forceupdateaffiliate)) {
|
||||
$prodsocpriceupd = new Productcustomerprice($this->db);
|
||||
$prodsocpriceupd->fetch($prodsocprice->lines [0]->id);
|
||||
|
||||
@ -793,7 +793,7 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
$resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
$this->error = $prodsocpriceupd->error;
|
||||
}
|
||||
}
|
||||
@ -810,7 +810,7 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
$resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
$this->error = $prodsocpriceupd->error;
|
||||
}
|
||||
}
|
||||
@ -821,11 +821,11 @@ class Productcustomerprice extends CommonObject
|
||||
if (empty($error)) {
|
||||
return 1;
|
||||
} else {
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
return - 1;
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -844,8 +844,8 @@ class Productcustomerprice extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error) {
|
||||
if (! $notrigger) {
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
@ -858,26 +858,26 @@ class Productcustomerprice extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_customer_price";
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error ++;
|
||||
$this->errors [] = "Error " . $this->db->lasterror();
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors [] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1 * $error;
|
||||
return -1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
@ -908,28 +908,28 @@ class Productcustomerprice extends CommonObject
|
||||
// ...
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone']='createfromclone';
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
$result = $object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0) {
|
||||
$this->error = $object->error;
|
||||
$this->errors=array_merge($this->errors, $object->errors);
|
||||
$this->errors = array_merge($this->errors, $object->errors);
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
}
|
||||
|
||||
unset($object->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (! $error) {
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,33 +62,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="position_name";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "position_name";
|
||||
|
||||
|
||||
$object = new Product($db);
|
||||
if ($id > 0 || ! empty($ref))
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
$result = $object->fetch($id, $ref);
|
||||
|
||||
if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
|
||||
elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
|
||||
if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
|
||||
elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
|
||||
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
|
||||
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
|
||||
{
|
||||
if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
|
||||
if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
|
||||
else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
|
||||
}
|
||||
}
|
||||
$modulepart='produit';
|
||||
$modulepart = 'produit';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array('id'=>$id);
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
@ -102,10 +102,10 @@ if (empty($reshook))
|
||||
$urlfile = GETPOST('urlfile', 'alpha');
|
||||
$filename = basename($urlfile);
|
||||
$filetomerge = new Propalmergepdfproduct($db);
|
||||
$filetomerge->fk_product=$object->id;
|
||||
$filetomerge->file_name=$filename;
|
||||
$result=$filetomerge->delete_by_file($user);
|
||||
if ($result<0) {
|
||||
$filetomerge->fk_product = $object->id;
|
||||
$filetomerge->file_name = $filename;
|
||||
$result = $filetomerge->delete_by_file($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($filetomerge->error, $filetomerge->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ if (empty($reshook))
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
}
|
||||
|
||||
if ($action=='filemerge')
|
||||
if ($action == 'filemerge')
|
||||
{
|
||||
$is_refresh = GETPOST('refresh');
|
||||
if (empty($is_refresh)) {
|
||||
@ -131,11 +131,11 @@ if ($action=='filemerge')
|
||||
$filetomerge = new Propalmergepdfproduct($db);
|
||||
|
||||
if ($conf->global->MAIN_MULTILANGS) {
|
||||
$result=$filetomerge->delete_by_product($user, $object->id, $lang_id);
|
||||
$result = $filetomerge->delete_by_product($user, $object->id, $lang_id);
|
||||
} else {
|
||||
$result=$filetomerge->delete_by_product($user, $object->id);
|
||||
$result = $filetomerge->delete_by_product($user, $object->id);
|
||||
}
|
||||
if ($result<0) {
|
||||
if ($result < 0) {
|
||||
setEventMessages($filetomerge->error, $filetomerge->errors, 'errors');
|
||||
}
|
||||
|
||||
@ -149,8 +149,8 @@ if ($action=='filemerge')
|
||||
$filetomerge->lang = $lang_id;
|
||||
}
|
||||
|
||||
$result=$filetomerge->create($user);
|
||||
if ($result<0) {
|
||||
$result = $filetomerge->create($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($filetomerge->error, $filetomerge->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -170,13 +170,13 @@ $helpurl = '';
|
||||
$shortlabel = dol_trunc($object->label, 16);
|
||||
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
|
||||
{
|
||||
$title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Documents');
|
||||
$helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Documents');
|
||||
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||
}
|
||||
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
|
||||
{
|
||||
$title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Documents');
|
||||
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Documents');
|
||||
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||
}
|
||||
|
||||
llxHeader('', $title, $helpurl);
|
||||
@ -234,8 +234,8 @@ if ($object->id)
|
||||
dol_fiche_end();
|
||||
|
||||
$permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
|
||||
$param = '&id=' . $object->id;
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
$param = '&id='.$object->id;
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
||||
|
||||
|
||||
// Merge propal PDF document PDF files
|
||||
@ -255,7 +255,7 @@ if ($object->id)
|
||||
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1);
|
||||
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
|
||||
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
|
||||
{
|
||||
$filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1));
|
||||
}
|
||||
@ -269,8 +269,8 @@ if ($object->id)
|
||||
print $langs->trans('PropalMergePdfProductActualFile');
|
||||
}
|
||||
|
||||
print '<form name="filemerge" action="' . DOL_URL_ROOT . '/product/document.php?id=' . $object->id . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<form name="filemerge" action="'.DOL_URL_ROOT.'/product/document.php?id='.$object->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="filemerge">';
|
||||
if (count($filetomerge->lines) == 0) {
|
||||
print $langs->trans('PropalMergePdfProductChooseFile');
|
||||
@ -291,7 +291,7 @@ if ($object->id)
|
||||
print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC');
|
||||
|
||||
if ($conf->global->MAIN_MULTILANGS) {
|
||||
print '<input type="submit" class="button" name="refresh" value="' . $langs->trans('Refresh') . '">';
|
||||
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans('Refresh').'">';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
@ -306,9 +306,9 @@ if ($object->id)
|
||||
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
if (array_key_exists($filetoadd['name'] . '_' . $default_lang, $filetomerge->lines))
|
||||
if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines))
|
||||
{
|
||||
$filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $default_lang);
|
||||
$filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang);
|
||||
$checked = ' checked ';
|
||||
}
|
||||
}
|
||||
@ -321,13 +321,13 @@ if ($object->id)
|
||||
}
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<input type="checkbox" ' . $checked . ' name="filetoadd[]" id="filetoadd" value="' . $filetoadd['name'] . '">' . $filename . '</input>';
|
||||
print '<input type="checkbox" '.$checked.' name="filetoadd[]" id="filetoadd" value="'.$filetoadd['name'].'">'.$filename.'</input>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td>';
|
||||
print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -56,20 +56,20 @@ $sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOST("page", 'int');
|
||||
if (empty($page) || $page < 0) $page = 0;
|
||||
if (! $sortfield) $sortfield="p.ref";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
||||
if (!$sortfield) $sortfield = "p.ref";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page ;
|
||||
$offset = $limit * $page;
|
||||
|
||||
// Load sale and categ filters
|
||||
$search_sale = GETPOST("search_sale");
|
||||
$search_categ = GETPOST("search_categ");
|
||||
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
$canvas=GETPOST("canvas");
|
||||
$objcanvas=null;
|
||||
if (! empty($canvas))
|
||||
$canvas = GETPOST("canvas");
|
||||
$objcanvas = null;
|
||||
if (!empty($canvas))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
@ -77,10 +77,10 @@ if (! empty($canvas))
|
||||
}
|
||||
|
||||
// Define virtualdiffersfromphysical
|
||||
$virtualdiffersfromphysical=0;
|
||||
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
|
||||
$virtualdiffersfromphysical = 0;
|
||||
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
|
||||
{
|
||||
$virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
|
||||
$virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
|
||||
}
|
||||
|
||||
|
||||
@ -91,18 +91,18 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$sref="";
|
||||
$snom="";
|
||||
$sall="";
|
||||
$tosell="";
|
||||
$tobuy="";
|
||||
$search_sale="";
|
||||
$search_categ="";
|
||||
$type="";
|
||||
$catid='';
|
||||
$toolowstock='';
|
||||
$fourn_id='';
|
||||
$sbarcode='';
|
||||
$sref = "";
|
||||
$snom = "";
|
||||
$sall = "";
|
||||
$tosell = "";
|
||||
$tobuy = "";
|
||||
$search_sale = "";
|
||||
$search_categ = "";
|
||||
$type = "";
|
||||
$catid = '';
|
||||
$toolowstock = '';
|
||||
$fourn_id = '';
|
||||
$sbarcode = '';
|
||||
}
|
||||
|
||||
|
||||
@ -111,50 +111,50 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
* View
|
||||
*/
|
||||
|
||||
$helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||
$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||
|
||||
$form=new Form($db);
|
||||
$htmlother=new FormOther($db);
|
||||
$form = new Form($db);
|
||||
$htmlother = new FormOther($db);
|
||||
|
||||
$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
|
||||
$sql.= ' p.fk_product_type, p.tms as datem,';
|
||||
$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
|
||||
$sql.= ' SUM(s.reel) as stock_physique';
|
||||
if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ', u.short_label as unit_short';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
|
||||
if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid';
|
||||
$sql .= ' p.fk_product_type, p.tms as datem,';
|
||||
$sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
|
||||
$sql .= ' SUM(s.reel) as stock_physique';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', u.short_label as unit_short';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid';
|
||||
// We'll need this table joined to the select in order to filter by categ
|
||||
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('product').")";
|
||||
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
|
||||
if ($sall) $sql.=natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
|
||||
if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('product').")";
|
||||
if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
|
||||
if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
|
||||
// if the type is not 1, we show all products (type = 0,2,3)
|
||||
if (dol_strlen($type))
|
||||
{
|
||||
if ($type==1)
|
||||
if ($type == 1)
|
||||
{
|
||||
$sql.= " AND p.fk_product_type = '1'";
|
||||
$sql .= " AND p.fk_product_type = '1'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND p.fk_product_type <> '1'";
|
||||
$sql .= " AND p.fk_product_type <> '1'";
|
||||
}
|
||||
}
|
||||
if ($sref) $sql.= natural_search('p.ref', $sref);
|
||||
if ($search_barcode) $sql.= natural_search('p.barcode', $search_barcode);
|
||||
if ($snom) $sql.= natural_search('p.label', $snom);
|
||||
if (! empty($tosell)) $sql.= " AND p.tosell = ".$tosell;
|
||||
if (! empty($tobuy)) $sql.= " AND p.tobuy = ".$tobuy;
|
||||
if (! empty($canvas)) $sql.= " AND p.canvas = '".$db->escape($canvas)."'";
|
||||
if($catid) $sql.= " AND cp.fk_categorie = ".$catid;
|
||||
if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
|
||||
if ($sref) $sql .= natural_search('p.ref', $sref);
|
||||
if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode);
|
||||
if ($snom) $sql .= natural_search('p.label', $snom);
|
||||
if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell;
|
||||
if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy;
|
||||
if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'";
|
||||
if ($catid) $sql .= " AND cp.fk_categorie = ".$catid;
|
||||
if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
|
||||
// Insert categ filter
|
||||
if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ);
|
||||
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
|
||||
$sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
|
||||
if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte";
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
|
||||
$sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
|
||||
if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte";
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
@ -169,7 +169,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -187,31 +187,31 @@ if ($resql)
|
||||
|
||||
if (isset($type))
|
||||
{
|
||||
if ($type==1) { $texte = $langs->trans("Services"); }
|
||||
if ($type == 1) { $texte = $langs->trans("Services"); }
|
||||
else { $texte = $langs->trans("Products"); }
|
||||
} else {
|
||||
$texte = $langs->trans("ProductsAndServices");
|
||||
}
|
||||
$texte.=' ('.$langs->trans("MenuStocks").')';
|
||||
$texte .= ' ('.$langs->trans("MenuStocks").')';
|
||||
|
||||
$param='';
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($sall) $param.="&sall=".urlencode($sall);
|
||||
if ($tosell) $param.="&tosell=".urlencode($tosell);
|
||||
if ($tobuy) $param.="&tobuy=".urlencode($tobuy);
|
||||
if ($type) $param.="&type=".urlencode($type);
|
||||
if ($fourn_id) $param.="&fourn_id=".urlencode($fourn_id);
|
||||
if ($snom) $param.="&snom=".urlencode($snom);
|
||||
if ($sref) $param.="&sref=".urlencode($sref);
|
||||
if ($search_sale) $param.="&search_sale=".urlencode($search_sale);
|
||||
if ($search_categ) $param.="&search_categ=".urlencode($search_categ);
|
||||
if ($toolowstock) $param.="&toolowstock=".urlencode($toolowstock);
|
||||
if ($sbarcode) $param.="&sbarcode=".urlencode($sbarcode);
|
||||
if ($catid) $param.="&catid=".urlencode($catid);
|
||||
$param = '';
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sall) $param .= "&sall=".urlencode($sall);
|
||||
if ($tosell) $param .= "&tosell=".urlencode($tosell);
|
||||
if ($tobuy) $param .= "&tobuy=".urlencode($tobuy);
|
||||
if ($type) $param .= "&type=".urlencode($type);
|
||||
if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id);
|
||||
if ($snom) $param .= "&snom=".urlencode($snom);
|
||||
if ($sref) $param .= "&sref=".urlencode($sref);
|
||||
if ($search_sale) $param .= "&search_sale=".urlencode($search_sale);
|
||||
if ($search_categ) $param .= "&search_categ=".urlencode($search_categ);
|
||||
if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock);
|
||||
if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode);
|
||||
if ($catid) $param .= "&catid=".urlencode($catid);
|
||||
|
||||
llxHeader("", $texte, $helpurl);
|
||||
|
||||
print '<form action="'. $_SERVER["PHP_SELF"] .'" method="post" name="formulaire">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
@ -220,7 +220,7 @@ if ($resql)
|
||||
|
||||
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit);
|
||||
|
||||
if (! empty($catid))
|
||||
if (!empty($catid))
|
||||
{
|
||||
print "<div id='ways'>";
|
||||
$c = new Categorie($db);
|
||||
@ -231,48 +231,48 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Filter on categories
|
||||
$moreforfilter='';
|
||||
if (! empty($conf->categorie->enabled))
|
||||
$moreforfilter = '';
|
||||
if (!empty($conf->categorie->enabled))
|
||||
{
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||
$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ');
|
||||
$moreforfilter.='</div>';
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans('Categories').': ';
|
||||
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ');
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock?' checked':'').'>';
|
||||
$moreforfilter.='</div>';
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock ? ' checked' : '').'>';
|
||||
$moreforfilter .= '</div>';
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$param='';
|
||||
if ($tosell) $param.="&tosell=".$tosell;
|
||||
if ($tobuy) $param.="&tobuy=".$tobuy;
|
||||
if ($type) $param.="&type=".$type;
|
||||
if ($fourn_id) $param.="&fourn_id=".$fourn_id;
|
||||
if ($snom) $param.="&snom=".$snom;
|
||||
if ($sref) $param.="&sref=".$sref;
|
||||
if ($toolowstock) $param.="&toolowstock=".$toolowstock;
|
||||
if ($search_categ) $param.="&search_categ=".$search_categ;
|
||||
$param = '';
|
||||
if ($tosell) $param .= "&tosell=".$tosell;
|
||||
if ($tobuy) $param .= "&tobuy=".$tobuy;
|
||||
if ($type) $param .= "&type=".$type;
|
||||
if ($fourn_id) $param .= "&fourn_id=".$fourn_id;
|
||||
if ($snom) $param .= "&snom=".$snom;
|
||||
if ($sref) $param .= "&sref=".$sref;
|
||||
if ($toolowstock) $param .= "&toolowstock=".$toolowstock;
|
||||
if ($search_categ) $param .= "&search_categ=".$search_categ;
|
||||
|
||||
$formProduct = new FormProduct($db);
|
||||
$formProduct->loadWarehouses();
|
||||
$warehouses_list = $formProduct->cache_warehouses;
|
||||
$nb_warehouse = count($warehouses_list);
|
||||
$colspan_warehouse = 1;
|
||||
if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse+1 : 1; }
|
||||
if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; }
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
|
||||
|
||||
// Fields title search
|
||||
print '<tr class="liste_titre_filter">';
|
||||
@ -283,7 +283,7 @@ if ($resql)
|
||||
print '<input class="flat" type="text" name="snom" size="8" value="'.$snom.'">';
|
||||
print '</td>';
|
||||
// Duration
|
||||
if (! empty($conf->service->enabled) && $type == 1)
|
||||
if (!empty($conf->service->enabled) && $type == 1)
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
@ -298,7 +298,7 @@ if ($resql)
|
||||
print '<td class="liste_titre" colspan="'.$colspan_warehouse.'"> </td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -307,14 +307,14 @@ if ($resql)
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", $param, "", "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", $param, "", "", $sortfield, $sortorder);
|
||||
if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right ');
|
||||
// Details per warehouse
|
||||
if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
|
||||
if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
|
||||
{
|
||||
if ($nb_warehouse>1) {
|
||||
if ($nb_warehouse > 1) {
|
||||
foreach ($warehouses_list as &$wh) {
|
||||
print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right ');
|
||||
}
|
||||
@ -322,7 +322,7 @@ if ($resql)
|
||||
}
|
||||
if ($virtualdiffersfromphysical) print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right ');
|
||||
// Units
|
||||
if (! empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre('');
|
||||
@ -335,7 +335,7 @@ if ($resql)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$product=new Product($db);
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->rowid);
|
||||
$product->load_stock();
|
||||
|
||||
@ -346,7 +346,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
print '<td>'.$product->label.'</td>';
|
||||
|
||||
if (! empty($conf->service->enabled) && $type == 1)
|
||||
if (!empty($conf->service->enabled) && $type == 1)
|
||||
{
|
||||
print '<td class="center">';
|
||||
if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear");
|
||||
@ -361,14 +361,14 @@ if ($resql)
|
||||
// Real stock
|
||||
print '<td class="right">';
|
||||
if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
|
||||
print $objp->stock_physique|0;
|
||||
print $objp->stock_physique | 0;
|
||||
print '</td>';
|
||||
|
||||
// Details per warehouse
|
||||
if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
|
||||
if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
|
||||
{
|
||||
if($nb_warehouse>1) {
|
||||
foreach($warehouses_list as &$wh) {
|
||||
if ($nb_warehouse > 1) {
|
||||
foreach ($warehouses_list as &$wh) {
|
||||
print '<td class="right">';
|
||||
print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real;
|
||||
print '</td>';
|
||||
@ -385,8 +385,8 @@ if ($resql)
|
||||
print '</td>';
|
||||
}
|
||||
// Units
|
||||
if (! empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
print '<td class="left">' . $objp->unit_short . '</td>';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
print '<td class="left">'.$objp->unit_short.'</td>';
|
||||
}
|
||||
print '<td class="right"><a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?idproduct='.$product->id.'">'.$langs->trans("Movements").'</a></td>';
|
||||
print '<td class="right nowrap">'.$product->LibStatut($objp->statut, 5, 0).'</td>';
|
||||
|
||||
@ -26,13 +26,13 @@
|
||||
* \brief File to offer a way to make an online signature for a particular Dolibarr entity
|
||||
*/
|
||||
|
||||
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
||||
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
||||
|
||||
// For MultiCompany module.
|
||||
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
|
||||
// TODO This should be useless. Because entity must be retreive from object ref and not from url.
|
||||
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
|
||||
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
|
||||
if (is_numeric($entity)) define("DOLENTITY", $entity);
|
||||
|
||||
require '../../main.inc.php';
|
||||
@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox"));
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Input are:
|
||||
// type ('invoice','order','contractline'),
|
||||
@ -55,15 +55,15 @@ $action=GETPOST('action', 'alpha');
|
||||
// tag (a free text, required if type is empty)
|
||||
// currency (iso code)
|
||||
|
||||
$suffix=GETPOST("suffix", 'alpha');
|
||||
$source=GETPOST("source", 'alpha');
|
||||
$ref=$REF=GETPOST("ref", 'alpha');
|
||||
$suffix = GETPOST("suffix", 'alpha');
|
||||
$source = GETPOST("source", 'alpha');
|
||||
$ref = $REF = GETPOST("ref", 'alpha');
|
||||
|
||||
if (empty($source)) $source='proposal';
|
||||
if (empty($source)) $source = 'proposal';
|
||||
|
||||
if (! $action)
|
||||
if (!$action)
|
||||
{
|
||||
if ($source && ! $ref)
|
||||
if ($source && !$ref)
|
||||
{
|
||||
print $langs->trans('ErrorBadParameters')." - ref missing";
|
||||
exit;
|
||||
@ -71,8 +71,8 @@ if (! $action)
|
||||
}
|
||||
|
||||
|
||||
$paymentmethod='';
|
||||
$validpaymentmethod=array();
|
||||
$paymentmethod = '';
|
||||
$validpaymentmethod = array();
|
||||
|
||||
|
||||
|
||||
@ -80,34 +80,34 @@ $validpaymentmethod=array();
|
||||
// Define $urlwithroot
|
||||
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
|
||||
$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
|
||||
|
||||
|
||||
// Complete urls for post treatment
|
||||
$SECUREKEY=GETPOST("securekey"); // Secure key
|
||||
$SECUREKEY = GETPOST("securekey"); // Secure key
|
||||
|
||||
if (! empty($source))
|
||||
if (!empty($source))
|
||||
{
|
||||
$urlok.='source='.urlencode($source).'&';
|
||||
$urlko.='source='.urlencode($source).'&';
|
||||
$urlok .= 'source='.urlencode($source).'&';
|
||||
$urlko .= 'source='.urlencode($source).'&';
|
||||
}
|
||||
if (! empty($REF))
|
||||
if (!empty($REF))
|
||||
{
|
||||
$urlok.='ref='.urlencode($REF).'&';
|
||||
$urlko.='ref='.urlencode($REF).'&';
|
||||
$urlok .= 'ref='.urlencode($REF).'&';
|
||||
$urlko .= 'ref='.urlencode($REF).'&';
|
||||
}
|
||||
if (! empty($SECUREKEY))
|
||||
if (!empty($SECUREKEY))
|
||||
{
|
||||
$urlok.='securekey='.urlencode($SECUREKEY).'&';
|
||||
$urlko.='securekey='.urlencode($SECUREKEY).'&';
|
||||
$urlok .= 'securekey='.urlencode($SECUREKEY).'&';
|
||||
$urlko .= 'securekey='.urlencode($SECUREKEY).'&';
|
||||
}
|
||||
if (! empty($entity))
|
||||
if (!empty($entity))
|
||||
{
|
||||
$urlok.='entity='.urlencode($entity).'&';
|
||||
$urlko.='entity='.urlencode($entity).'&';
|
||||
$urlok .= 'entity='.urlencode($entity).'&';
|
||||
$urlko .= 'entity='.urlencode($entity).'&';
|
||||
}
|
||||
$urlok=preg_replace('/&$/', '', $urlok); // Remove last &
|
||||
$urlko=preg_replace('/&$/', '', $urlko); // Remove last &
|
||||
$urlok = preg_replace('/&$/', '', $urlok); // Remove last &
|
||||
$urlko = preg_replace('/&$/', '', $urlko); // Remove last &
|
||||
|
||||
$creditor = $mysoc->name;
|
||||
|
||||
@ -127,16 +127,16 @@ if ($action == 'dosign')
|
||||
* View
|
||||
*/
|
||||
|
||||
$head='';
|
||||
if (! empty($conf->global->MAIN_SIGN_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_SIGN_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
|
||||
$head = '';
|
||||
if (!empty($conf->global->MAIN_SIGN_CSS_URL)) $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_SIGN_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
|
||||
|
||||
$conf->dol_hide_topmenu=1;
|
||||
$conf->dol_hide_leftmenu=1;
|
||||
$conf->dol_hide_topmenu = 1;
|
||||
$conf->dol_hide_leftmenu = 1;
|
||||
|
||||
llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
|
||||
|
||||
// Check link validity
|
||||
if (! empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
|
||||
if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
|
||||
{
|
||||
$langs->load("errors");
|
||||
dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
|
||||
@ -161,24 +161,24 @@ print '<!-- Form to sign -->'."\n";
|
||||
print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
|
||||
|
||||
// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
|
||||
$width=0;
|
||||
$width = 0;
|
||||
// Define logo and logosmall
|
||||
$logosmall=$mysoc->logo_small;
|
||||
$logo=$mysoc->logo;
|
||||
$paramlogo='ONLINE_SIGN_LOGO_'.$suffix;
|
||||
if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo;
|
||||
elseif (! empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall=$conf->global->ONLINE_SIGN_LOGO;
|
||||
$logosmall = $mysoc->logo_small;
|
||||
$logo = $mysoc->logo;
|
||||
$paramlogo = 'ONLINE_SIGN_LOGO_'.$suffix;
|
||||
if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo;
|
||||
elseif (!empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall = $conf->global->ONLINE_SIGN_LOGO;
|
||||
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
|
||||
// Define urllogo
|
||||
$urllogo='';
|
||||
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
|
||||
$urllogo = '';
|
||||
if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
||||
}
|
||||
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
|
||||
elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
||||
$width=96;
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
||||
$width = 96;
|
||||
}
|
||||
// Output html code for logo
|
||||
if ($urllogo)
|
||||
@ -191,18 +191,18 @@ if ($urllogo)
|
||||
}
|
||||
|
||||
// Output introduction text
|
||||
$text='';
|
||||
if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT))
|
||||
$text = '';
|
||||
if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT))
|
||||
{
|
||||
$langs->load("members");
|
||||
if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text.=$langs->trans($reg[1])."<br>\n";
|
||||
else $text.=$conf->global->ONLINE_SIGN_NEWFORM_TEXT."<br>\n";
|
||||
$text='<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
|
||||
if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."<br>\n";
|
||||
else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."<br>\n";
|
||||
$text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
|
||||
}
|
||||
if (empty($text))
|
||||
{
|
||||
$text.='<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text.='<tr><td class="textpublicpayment">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'<br><br></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'<br><br></td></tr>'."\n";
|
||||
}
|
||||
print $text;
|
||||
|
||||
@ -211,47 +211,47 @@ print '<tr><td align="center">';
|
||||
print '<table with="100%" id="tablepublicpayment">';
|
||||
print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("ThisIsInformationOnDocumentToSign").' :</td></tr>'."\n";
|
||||
|
||||
$found=false;
|
||||
$error=0;
|
||||
$var=false;
|
||||
$found = false;
|
||||
$error = 0;
|
||||
$var = false;
|
||||
|
||||
// Payment on customer order
|
||||
if ($source == 'proposal')
|
||||
{
|
||||
$found=true;
|
||||
$found = true;
|
||||
$langs->load("proposal");
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
|
||||
$proposal=new Propal($db);
|
||||
$result=$proposal->fetch('', $ref);
|
||||
$proposal = new Propal($db);
|
||||
$result = $proposal->fetch('', $ref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$mesg=$proposal->error;
|
||||
$mesg = $proposal->error;
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$proposal->fetch_thirdparty($proposal->socid);
|
||||
$result = $proposal->fetch_thirdparty($proposal->socid);
|
||||
}
|
||||
|
||||
// Creditor
|
||||
|
||||
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
|
||||
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
|
||||
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Creditor");
|
||||
print '</td><td class="CTableRow'.($var ? '1' : '2').'"><b>'.$creditor.'</b>';
|
||||
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Debitor
|
||||
|
||||
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
|
||||
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$proposal->thirdparty->name.'</b>';
|
||||
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("ThirdParty");
|
||||
print '</td><td class="CTableRow'.($var ? '1' : '2').'"><b>'.$proposal->thirdparty->name.'</b>';
|
||||
|
||||
// Object
|
||||
|
||||
$text='<b>'.$langs->trans("SignatureProposalRef", $proposal->ref).'</b>';
|
||||
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
||||
$text = '<b>'.$langs->trans("SignatureProposalRef", $proposal->ref).'</b>';
|
||||
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow'.($var ? '1' : '2').'">'.$text;
|
||||
print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
|
||||
print '<input type="hidden" name="ref" value="'.$proposal->ref.'">';
|
||||
print '</td></tr>'."\n";
|
||||
@ -259,7 +259,7 @@ if ($source == 'proposal')
|
||||
|
||||
|
||||
|
||||
if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
|
||||
if (!$found && !$mesg) $mesg = $langs->trans("ErrorBadParameters");
|
||||
|
||||
if ($mesg) print '<tr><td align="center" colspan="2"><br><div class="warning">'.$mesg.'</div></td></tr>'."\n";
|
||||
|
||||
@ -268,7 +268,7 @@ print "\n";
|
||||
|
||||
if ($action != 'dosign')
|
||||
{
|
||||
if ($found && ! $error) // We are in a management option and no error
|
||||
if ($found && !$error) // We are in a management option and no error
|
||||
{
|
||||
}
|
||||
else
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
* \ingroup core
|
||||
* \brief Class file to manage forms into resource module
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php";
|
||||
|
||||
|
||||
/**
|
||||
@ -39,14 +39,14 @@ class FormResource
|
||||
*/
|
||||
public $db;
|
||||
|
||||
public $substit=array();
|
||||
public $substit = array();
|
||||
|
||||
public $param=array();
|
||||
public $param = array();
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error='';
|
||||
public $error = '';
|
||||
|
||||
|
||||
/**
|
||||
@ -79,10 +79,10 @@ class FormResource
|
||||
public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf,$user,$langs;
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$out='';
|
||||
$outarray=array();
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
|
||||
$resourcestat = new Dolresource($this->db);
|
||||
|
||||
@ -91,20 +91,20 @@ class FormResource
|
||||
if ($outputmode != 2)
|
||||
{
|
||||
$out = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
}
|
||||
|
||||
if ($resourcestat)
|
||||
{
|
||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && ! $forcecombo)
|
||||
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo)
|
||||
{
|
||||
//$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2);
|
||||
$out.= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
|
||||
$out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
|
||||
}
|
||||
|
||||
// Construct $out and $outarray
|
||||
$out.= '<select id="'.$htmlname.'" class="flat minwidth200" name="'.$htmlname.'">'."\n";
|
||||
if ($showempty) $out.= '<option value="-1"> </option>'."\n";
|
||||
$out .= '<select id="'.$htmlname.'" class="flat minwidth200" name="'.$htmlname.'">'."\n";
|
||||
if ($showempty) $out .= '<option value="-1"> </option>'."\n";
|
||||
|
||||
$num = 0;
|
||||
if (is_array($resourcestat->lines)) $num = count($resourcestat->lines);
|
||||
@ -115,34 +115,34 @@ class FormResource
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$resourceclass=ucfirst($resourcestat->lines[$i]->element);
|
||||
$resourceclass = ucfirst($resourcestat->lines[$i]->element);
|
||||
|
||||
$label=$resourcestat->lines[$i]->ref?$resourcestat->lines[$i]->ref:''.$resourcestat->lines[$i]->label;
|
||||
if ($resourceclass != 'Dolresource') $label.=' ('.$langs->trans($resourceclass).')';
|
||||
$label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : ''.$resourcestat->lines[$i]->label;
|
||||
if ($resourceclass != 'Dolresource') $label .= ' ('.$langs->trans($resourceclass).')';
|
||||
|
||||
if ($selected > 0 && $selected == $resourcestat->lines[$i]->id)
|
||||
{
|
||||
$out.= '<option value="'.$resourcestat->lines[$i]->id.'" selected>'.$label.'</option>';
|
||||
$out .= '<option value="'.$resourcestat->lines[$i]->id.'" selected>'.$label.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= '<option value="'.$resourcestat->lines[$i]->id.'">'.$label.'</option>';
|
||||
$out .= '<option value="'.$resourcestat->lines[$i]->id.'">'.$label.'</option>';
|
||||
}
|
||||
|
||||
array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label));
|
||||
|
||||
$i++;
|
||||
if (($i % 10) == 0) $out.="\n";
|
||||
if (($i % 10) == 0) $out .= "\n";
|
||||
}
|
||||
}
|
||||
$out.= '</select>'."\n";
|
||||
$out.= ajax_combobox($htmlname);
|
||||
$out .= '</select>'."\n";
|
||||
$out .= ajax_combobox($htmlname);
|
||||
|
||||
if ($outputmode != 2)
|
||||
{
|
||||
$out.= '<input type="submit" class="button" value="'.$langs->trans("Search").'"> ';
|
||||
$out .= '<input type="submit" class="button" value="'.$langs->trans("Search").'"> ';
|
||||
|
||||
$out.= '</form>';
|
||||
$out .= '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -170,22 +170,22 @@ class FormResource
|
||||
public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs,$user;
|
||||
global $langs, $user;
|
||||
|
||||
$resourcestat = new Dolresource($this->db);
|
||||
|
||||
dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
|
||||
|
||||
$filterarray=array();
|
||||
$filterarray = array();
|
||||
|
||||
if ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',', $filtertype);
|
||||
if ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype);
|
||||
|
||||
$resourcestat->load_cache_code_type_resource();
|
||||
print '<select id="select'.$htmlname.'" class="flat maxwidthonsmartphone select_'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if ($empty) print '<option value=""> </option>';
|
||||
if (is_array($resourcestat->cache_code_type_resource) && count($resourcestat->cache_code_type_resource))
|
||||
{
|
||||
foreach($resourcestat->cache_code_type_resource as $id => $arraytypes)
|
||||
foreach ($resourcestat->cache_code_type_resource as $id => $arraytypes)
|
||||
{
|
||||
// We discard empty line if showempty is on because an empty line has already been output.
|
||||
if ($empty && empty($arraytypes['code'])) continue;
|
||||
@ -198,15 +198,15 @@ class FormResource
|
||||
if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected';
|
||||
elseif ($selected == $id) print ' selected';
|
||||
print '>';
|
||||
if ($format == 0) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']);
|
||||
elseif ($format == 1) $value=$arraytypes['code'];
|
||||
elseif ($format == 2) $value=($maxlength?dol_trunc($arraytypes['label'], $maxlength):$arraytypes['label']);
|
||||
elseif ($format == 3) $value=$arraytypes['code'];
|
||||
print $value?$value:' ';
|
||||
if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
|
||||
elseif ($format == 1) $value = $arraytypes['code'];
|
||||
elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
|
||||
elseif ($format == 3) $value = $arraytypes['code'];
|
||||
print $value ? $value : ' ';
|
||||
print '</option>';
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$this->company = new Societe($this->db);
|
||||
|
||||
if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) {
|
||||
if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) {
|
||||
static::$FIELDS[] = 'email';
|
||||
}
|
||||
}
|
||||
@ -121,24 +121,24 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
||||
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as t";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql.= " WHERE t.fk_stcomm = st.id";
|
||||
if ($mode == 1) $sql.= " AND t.client IN (1, 3)";
|
||||
if ($mode == 2) $sql.= " AND t.client IN (2, 3)";
|
||||
if ($mode == 3) $sql.= " AND t.client IN (0)";
|
||||
if ($mode == 4) $sql.= " AND t.fournisseur IN (1)";
|
||||
$sql.= ' AND t.entity IN ('.getEntity('societe').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql .= " WHERE t.fk_stcomm = st.id";
|
||||
if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
|
||||
if ($mode == 2) $sql .= " AND t.client IN (2, 3)";
|
||||
if ($mode == 3) $sql .= " AND t.client IN (0)";
|
||||
if ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
|
||||
$sql .= ' AND t.entity IN ('.getEntity('societe').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
|
||||
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
|
||||
if ($socid) $sql.= " AND t.rowid IN (".$socids.")";
|
||||
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
if ($socid) $sql .= " AND t.rowid IN (".$socids.")";
|
||||
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
// Insert sale filter
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
@ -147,15 +147,15 @@ class Thirdparties extends DolibarrApi
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -164,7 +164,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -176,7 +176,7 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$soc_static = new Societe($db);
|
||||
if($soc_static->fetch($obj->rowid)) {
|
||||
if ($soc_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($soc_static);
|
||||
}
|
||||
$i++;
|
||||
@ -185,7 +185,7 @@ class Thirdparties extends DolibarrApi
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'Thirdparties not found');
|
||||
}
|
||||
return $obj_ret;
|
||||
@ -199,13 +199,13 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
if ($this->company->create(DolibarrApiAccess::$user) < 0)
|
||||
@ -223,25 +223,25 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
|
||||
if($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
|
||||
if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
|
||||
return $this->get($id);
|
||||
|
||||
return false;
|
||||
@ -272,27 +272,27 @@ class Thirdparties extends DolibarrApi
|
||||
throw new RestException(400, 'Try to merge a thirdparty into itself');
|
||||
}
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id); // include the fetch of extra fields
|
||||
if( ! $result ) {
|
||||
$result = $this->company->fetch($id); // include the fetch of extra fields
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->companytoremove = new Societe($db);
|
||||
|
||||
$result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields
|
||||
if( ! $result ) {
|
||||
$result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class Thirdparties extends DolibarrApi
|
||||
// Recopy some data
|
||||
$object->client = $object->client | $soc_origin->client;
|
||||
$object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
|
||||
$listofproperties=array(
|
||||
$listofproperties = array(
|
||||
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
|
||||
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
|
||||
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
|
||||
@ -323,7 +323,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
// Concat some data
|
||||
$listofproperties=array(
|
||||
$listofproperties = array(
|
||||
'note_public', 'note_private'
|
||||
);
|
||||
foreach ($listofproperties as $property)
|
||||
@ -367,7 +367,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
// Move links
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$objects = array(
|
||||
'Adherent' => '/adherents/class/adherent.class.php',
|
||||
@ -422,12 +422,12 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id);
|
||||
$object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id);
|
||||
|
||||
// Call trigger
|
||||
$result=$object->call_trigger('COMPANY_MODIFY', $user);
|
||||
$result = $object->call_trigger('COMPANY_MODIFY', $user);
|
||||
if ($result < 0)
|
||||
{
|
||||
//setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -436,7 +436,7 @@ class Thirdparties extends DolibarrApi
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
//We finally remove the old thirdparty
|
||||
if ($soc_origin->delete($soc_origin->id, $user) < 1)
|
||||
@ -469,14 +469,14 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->supprimer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->company->oldcopy = clone $this->company;
|
||||
@ -498,12 +498,12 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result )
|
||||
if (!$result)
|
||||
{
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
@ -537,24 +537,24 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function addCategory($id, $category_id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
$category = new Categorie($this->db);
|
||||
$result = $category->fetch($category_id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -575,24 +575,24 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function deleteCategory($id, $category_id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
$category = new Categorie($this->db);
|
||||
$result = $category->fetch($category_id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -616,12 +616,12 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result )
|
||||
if (!$result)
|
||||
{
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
@ -655,24 +655,24 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function addSupplierCategory($id, $category_id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
$category = new Categorie($this->db);
|
||||
$result = $category->fetch($category_id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -693,24 +693,24 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function deleteSupplierCategory($id, $category_id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
$category = new Categorie($this->db);
|
||||
$result = $category->fetch($category_id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -738,20 +738,20 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -782,20 +782,20 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -825,20 +825,20 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -868,20 +868,20 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -935,14 +935,14 @@ class Thirdparties extends DolibarrApi
|
||||
if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
|
||||
if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if( ! $result ) {
|
||||
if (!$result) {
|
||||
throw new RestException(503, $this->db->lasterror());
|
||||
} else {
|
||||
$num = $this->db->num_rows($result);
|
||||
while ( $obj = $this->db->fetch_object($result) ) {
|
||||
while ($obj = $this->db->fetch_object($result)) {
|
||||
$obj_ret[] = $obj;
|
||||
}
|
||||
}
|
||||
@ -967,14 +967,14 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function getInvoicesQualifiedForReplacement($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -985,7 +985,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$invoice = new Facture($this->db);
|
||||
$result = $invoice->list_replacable_invoices($id);
|
||||
if( $result < 0) {
|
||||
if ($result < 0) {
|
||||
throw new RestException(405, $this->thirdparty->error);
|
||||
}
|
||||
|
||||
@ -1009,14 +1009,14 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function getInvoicesQualifiedForCreditNote($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -1027,7 +1027,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$invoice = new Facture($this->db);
|
||||
$result = $invoice->list_qualified_avoir_invoices($id);
|
||||
if( $result < 0) {
|
||||
if ($result < 0) {
|
||||
throw new RestException(405, $this->thirdparty->error);
|
||||
}
|
||||
|
||||
@ -1047,14 +1047,14 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($id)) {
|
||||
if (empty($id)) {
|
||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -1063,18 +1063,18 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
|
||||
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
||||
$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql.= " WHERE fk_soc = ".$id." ";
|
||||
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE fk_soc = ".$id." ";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0 ){
|
||||
if ($result->num_rows == 0) {
|
||||
throw new RestException(404, 'Account not found');
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
|
||||
$accounts = array();
|
||||
|
||||
@ -1085,13 +1085,13 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$account = new CompanyBankAccount($db);
|
||||
if($account->fetch($obj->rowid)) {
|
||||
if ($account->fetch($obj->rowid)) {
|
||||
$accounts[] = $account;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
throw new RestException(404, 'Account not found');
|
||||
}
|
||||
|
||||
@ -1124,7 +1124,7 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function createCompanyBankAccount($id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@ -1132,7 +1132,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$account->socid = $id;
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1159,7 +1159,7 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@ -1167,12 +1167,12 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$account->fetch($bankaccount_id, $id, -1, '');
|
||||
|
||||
if($account->socid != $id){
|
||||
if ($account->socid != $id) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1194,7 +1194,7 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
public function deleteCompanyBankAccount($id, $bankaccount_id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@ -1202,7 +1202,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$account->fetch($bankaccount_id);
|
||||
|
||||
if(!$account->socid == $id)
|
||||
if (!$account->socid == $id)
|
||||
throw new RestException(401);
|
||||
|
||||
return $account->delete(DolibarrApiAccess::$user);
|
||||
@ -1222,12 +1222,12 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals"));
|
||||
$this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals"));
|
||||
|
||||
$this->company->fetch($id);
|
||||
|
||||
$action = 'builddoc';
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer)
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer)
|
||||
throw new RestException(401);
|
||||
|
||||
$this->company->setDocModel(DolibarrApiAccess::$user, $model);
|
||||
@ -1235,32 +1235,32 @@ class Thirdparties extends DolibarrApi
|
||||
$this->company->fk_bank = $this->company->fk_account;
|
||||
|
||||
$outputlangs = $this->langs;
|
||||
$newlang='';
|
||||
$newlang = '';
|
||||
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09');
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ...
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty
|
||||
if (! empty($newlang)) {
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ...
|
||||
if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
// To be sure vars is defined
|
||||
$hidedetails = $hidedesc = $hideref = 0;
|
||||
$moreparams=null;
|
||||
if (empty($hidedetails)) $hidedetails=0;
|
||||
if (empty($hidedesc)) $hidedesc=0;
|
||||
if (empty($hideref)) $hideref=0;
|
||||
if (empty($moreparams)) $moreparams=null;
|
||||
$moreparams = null;
|
||||
if (empty($hidedetails)) $hidedetails = 0;
|
||||
if (empty($hidedesc)) $hidedesc = 0;
|
||||
if (empty($hideref)) $hideref = 0;
|
||||
if (empty($moreparams)) $moreparams = null;
|
||||
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql.= " WHERE fk_soc = ".$id." ";
|
||||
if ($companybankid) $sql.= " AND id = ".$companybankid."";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE fk_soc = ".$id." ";
|
||||
if ($companybankid) $sql .= " AND id = ".$companybankid."";
|
||||
|
||||
$i=0;
|
||||
$accounts=array();
|
||||
$i = 0;
|
||||
$accounts = array();
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -1321,11 +1321,11 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
if(!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
@ -1333,16 +1333,16 @@ class Thirdparties extends DolibarrApi
|
||||
* We select all the records that match the socid
|
||||
*/
|
||||
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
|
||||
$sql.= " WHERE fk_soc = $id";
|
||||
if($site) $sql .= " AND site ='$site'";
|
||||
$sql .= " WHERE fk_soc = $id";
|
||||
if ($site) $sql .= " AND site ='$site'";
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0){
|
||||
if ($result->num_rows == 0) {
|
||||
throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.');
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
|
||||
$accounts = array();
|
||||
|
||||
@ -1352,7 +1352,7 @@ class Thirdparties extends DolibarrApi
|
||||
$obj = $db->fetch_object($result);
|
||||
$account = new SocieteAccount($db);
|
||||
|
||||
if($account->fetch($obj->rowid)) {
|
||||
if ($account->fetch($obj->rowid)) {
|
||||
$accounts[] = $account;
|
||||
}
|
||||
$i++;
|
||||
@ -1398,25 +1398,25 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
if(!isset($request_data['site'])) {
|
||||
if (!isset($request_data['site'])) {
|
||||
throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !');
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' ";
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' ";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0 ){
|
||||
if ($result->num_rows == 0) {
|
||||
$account = new SocieteAccount($this->db);
|
||||
if(!isset($request_data['login'])) {
|
||||
if (!isset($request_data['login'])) {
|
||||
$account->login = "";
|
||||
}
|
||||
$account->fk_soc = $id;
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1457,7 +1457,7 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@ -1465,16 +1465,16 @@ class Thirdparties extends DolibarrApi
|
||||
$result = $db->query($sql);
|
||||
|
||||
// We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one.
|
||||
if($result->num_rows == 0 ){
|
||||
if(!isset($request_data['key_account'])) {
|
||||
if ($result->num_rows == 0) {
|
||||
if (!isset($request_data['key_account'])) {
|
||||
throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !');
|
||||
}
|
||||
$account = new SocieteAccount($this->db);
|
||||
if(!isset($request_data['login'])) {
|
||||
if (!isset($request_data['login'])) {
|
||||
$account->login = "";
|
||||
}
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1501,13 +1501,13 @@ class Thirdparties extends DolibarrApi
|
||||
$account->id = $obj->rowid;
|
||||
$account->fk_soc = $id;
|
||||
$account->site = $site;
|
||||
if(!isset($request_data['login'])) {
|
||||
if (!isset($request_data['login'])) {
|
||||
$account->login = "";
|
||||
}
|
||||
$account->fk_user_creat = $obj->fk_user_creat;
|
||||
$account->date_creation = $obj->date_creation;
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1539,30 +1539,30 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' ";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0 ){
|
||||
if ($result->num_rows == 0) {
|
||||
throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist.");
|
||||
} else {
|
||||
// If the user tries to edit the site member, we check first if
|
||||
if(isset($request_data['site']) && $request_data['site'] !== $site) {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' ";
|
||||
if (isset($request_data['site']) && $request_data['site'] !== $site) {
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' ";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows !== 0)
|
||||
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key.");
|
||||
if ($result->num_rows !== 0)
|
||||
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
|
||||
}
|
||||
|
||||
$obj = $db->fetch_object($result);
|
||||
$account = new SocieteAccount($this->db);
|
||||
$account->fetch($obj->rowid);
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
foreach ($request_data as $field => $value) {
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
@ -1593,21 +1593,21 @@ class Thirdparties extends DolibarrApi
|
||||
global /** @var Database $db */
|
||||
$db;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' ";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0 ){
|
||||
if ($result->num_rows == 0) {
|
||||
throw new RestException(404);
|
||||
} else {
|
||||
$obj = $db->fetch_object($result);
|
||||
$account = new SocieteAccount($this->db);
|
||||
$account->fetch($obj->rowid);
|
||||
|
||||
if($account->delete(DolibarrApiAccess::$user) < 0) {
|
||||
if ($account->delete(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error while deleting $site gateway attached to this third party");
|
||||
}
|
||||
}
|
||||
@ -1630,7 +1630,7 @@ class Thirdparties extends DolibarrApi
|
||||
global /** @var Database $db */
|
||||
$db;
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@ -1639,14 +1639,14 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
|
||||
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id ";
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($result->num_rows == 0 ){
|
||||
if ($result->num_rows == 0) {
|
||||
throw new RestException(404, 'This third party does not have any gateway attached or does not exist.');
|
||||
} else {
|
||||
$i=0;
|
||||
$i = 0;
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
while ($i < $num)
|
||||
@ -1655,7 +1655,7 @@ class Thirdparties extends DolibarrApi
|
||||
$account = new SocieteAccount($db);
|
||||
$account->fetch($obj->rowid);
|
||||
|
||||
if($account->delete(DolibarrApiAccess::$user) < 0) {
|
||||
if ($account->delete(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error while deleting gateways attached to this third party');
|
||||
}
|
||||
$i++;
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
* \brief File of class to manage bank accounts description of third parties
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -81,34 +81,34 @@ class CompanyBankAccount extends Account
|
||||
public function create(User $user = null, $notrigger = 0)
|
||||
{
|
||||
$now = dol_now();
|
||||
$error = 0;
|
||||
$error = 0;
|
||||
// Correct default_rib to be sure to have always one default
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$numrows=$this->db->num_rows($result);
|
||||
$numrows = $this->db->num_rows($result);
|
||||
if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
|
||||
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
|
||||
$sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
|
||||
$resql=$this->db->query($sql);
|
||||
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->affected_rows($resql))
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
|
||||
|
||||
if (! $notrigger)
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('COMPANY_RIB_CREATE', $user);
|
||||
$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -215,14 +215,14 @@ class CompanyBankAccount extends Account
|
||||
if (empty($id) && empty($socid)) return -1;
|
||||
|
||||
$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
||||
$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql.= " WHERE rowid = ".$id;
|
||||
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE rowid = ".$id;
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " WHERE fk_soc = ".$socid;
|
||||
if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
|
||||
if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
|
||||
$sql .= " WHERE fk_soc = ".$socid;
|
||||
if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
|
||||
if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -232,10 +232,10 @@ class CompanyBankAccount extends Account
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
|
||||
$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->type = $obj->type;
|
||||
$this->id = $obj->rowid;
|
||||
$this->type = $obj->type;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->bank = $obj->bank;
|
||||
$this->code_banque = $obj->code_banque;
|
||||
@ -243,7 +243,7 @@ class CompanyBankAccount extends Account
|
||||
$this->number = $obj->number;
|
||||
$this->cle_rib = $obj->cle_rib;
|
||||
$this->bic = $obj->bic;
|
||||
$this->iban = $obj->iban;
|
||||
$this->iban = $obj->iban;
|
||||
$this->domiciliation = $obj->domiciliation;
|
||||
$this->proprio = $obj->proprio;
|
||||
$this->owner_address = $obj->owner_address;
|
||||
@ -279,31 +279,31 @@ class CompanyBankAccount extends Account
|
||||
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('COMPANY_RIB_DELETE', $user);
|
||||
$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
|
||||
$sql .= " WHERE rowid = " . $this->id;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if (! $this->db->query($sql))
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
@ -311,7 +311,7 @@ class CompanyBankAccount extends Account
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
return -1 * $error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ class CompanyBankAccount extends Account
|
||||
{
|
||||
$rib = '';
|
||||
|
||||
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
|
||||
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) {
|
||||
if ($this->label && $displayriblabel) {
|
||||
$rib = $this->label." : ";
|
||||
}
|
||||
@ -345,7 +345,7 @@ class CompanyBankAccount extends Account
|
||||
public function setAsDefault($rib = 0)
|
||||
{
|
||||
$sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql1.= " WHERE rowid = ".($rib?$rib:$this->id);
|
||||
$sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id);
|
||||
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result1 = $this->db->query($sql1);
|
||||
@ -362,12 +362,12 @@ class CompanyBankAccount extends Account
|
||||
$this->db->begin();
|
||||
|
||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
|
||||
$sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
|
||||
$sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result2 = $this->db->query($sql2);
|
||||
|
||||
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
|
||||
$sql3.= " WHERE rowid = ".$obj->id;
|
||||
$sql3 .= " WHERE rowid = ".$obj->id;
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result3 = $this->db->query($sql3);
|
||||
|
||||
|
||||
@ -102,19 +102,19 @@ $stripeacc = $stripe->getStripeAccount($service);
|
||||
}*/
|
||||
|
||||
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('paiementcard','globalcard'));
|
||||
$hookmanager->initHooks(array('paiementcard', 'globalcard'));
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array('socid'=>$socid);
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('socid'=>$socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes'))
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
@ -125,7 +125,7 @@ if (empty($reshook))
|
||||
$atleastonepaymentnotnull = 0;
|
||||
|
||||
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
|
||||
$tmpinvoice=new Facture($db);
|
||||
$tmpinvoice = new Facture($db);
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (substr($key, 0, 7) == 'amount_')
|
||||
@ -133,16 +133,16 @@ if (empty($reshook))
|
||||
$cursorfacid = substr($key, 7);
|
||||
$amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
|
||||
$totalpayment = $totalpayment + $amounts[$cursorfacid];
|
||||
if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
|
||||
$result=$tmpinvoice->fetch($cursorfacid);
|
||||
if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
|
||||
$result = $tmpinvoice->fetch($cursorfacid);
|
||||
if ($result <= 0) dol_print_error($db);
|
||||
$amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
|
||||
$amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
|
||||
if ($amounts[$cursorfacid])
|
||||
{
|
||||
// Check amount
|
||||
if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
|
||||
{
|
||||
$addwarning=1;
|
||||
$addwarning = 1;
|
||||
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
|
||||
}
|
||||
// Check date
|
||||
@ -154,23 +154,23 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
$formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]);
|
||||
$formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]);
|
||||
}
|
||||
elseif (substr($key, 0, 21) == 'multicurrency_amount_')
|
||||
{
|
||||
$cursorfacid = substr($key, 21);
|
||||
$multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
|
||||
$multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
|
||||
if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
|
||||
$result=$tmpinvoice->fetch($cursorfacid);
|
||||
if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
|
||||
$result = $tmpinvoice->fetch($cursorfacid);
|
||||
if ($result <= 0) dol_print_error($db);
|
||||
$multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
|
||||
$multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
|
||||
if ($multicurrency_amounts[$cursorfacid])
|
||||
{
|
||||
// Check amount
|
||||
if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid])))
|
||||
{
|
||||
$addwarning=1;
|
||||
$addwarning = 1;
|
||||
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
|
||||
}
|
||||
// Check date
|
||||
@ -182,7 +182,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
$formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int'));
|
||||
$formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ if (empty($reshook))
|
||||
$error++;
|
||||
}*/
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
// If bank module is on, account is required to enter a payment
|
||||
if (GETPOST('accountid') <= 0)
|
||||
@ -242,7 +242,7 @@ if (empty($reshook))
|
||||
*/
|
||||
if ($action == 'confirm_paiement' && $confirm == 'yes')
|
||||
{
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$datepaye = dol_now();
|
||||
|
||||
@ -264,7 +264,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
|
||||
if (GETPOST('accountid') <= 0)
|
||||
@ -282,34 +282,34 @@ if (empty($reshook))
|
||||
|
||||
if (is_object($stripe) && $stripeacc)
|
||||
{
|
||||
$customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
$customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
|
||||
if ($customerstripe->id) {
|
||||
$listofsources=$customerstripe->sources->data;
|
||||
$listofsources = $customerstripe->sources->data;
|
||||
}
|
||||
}
|
||||
|
||||
$stripeamount=0;
|
||||
$stripeamount = 0;
|
||||
foreach ($amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
$stripeamount+=price2num($value, 'MT');
|
||||
$stripeamount += price2num($value, 'MT');
|
||||
}
|
||||
|
||||
if (preg_match('/acct_/i', $source))
|
||||
{
|
||||
$paiementcode ="VIR";
|
||||
$paiementcode = "VIR";
|
||||
}
|
||||
elseif (preg_match('/card_/i', $source))
|
||||
{
|
||||
$paiementcode ="CB";
|
||||
$paiementcode = "CB";
|
||||
}
|
||||
elseif (preg_match('/src_/i', $source))
|
||||
{
|
||||
$customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
$customer2 = $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
$src = $customer2->sources->retrieve("$source");
|
||||
if ($src->type=='card')
|
||||
if ($src->type == 'card')
|
||||
{
|
||||
$paiementcode ="CB";
|
||||
$paiementcode = "CB";
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,17 +319,17 @@ if (empty($reshook))
|
||||
$societe->fetch($facture->socid);
|
||||
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
|
||||
|
||||
$stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_...
|
||||
$stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_...
|
||||
|
||||
$charge=$stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus);
|
||||
$charge = $stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Creation of payment line
|
||||
$paiement = new Paiement($db);
|
||||
$paiement->datepaye = $datepaye;
|
||||
$paiement->amounts = $amounts; // Array with all payments dispatching
|
||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||
$paiement->amounts = $amounts; // Array with all payments dispatching
|
||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||
$paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement');
|
||||
$paiement->num_paiement = $charge->message;
|
||||
$paiement->note = GETPOST('comment');
|
||||
@ -337,7 +337,7 @@ if (empty($reshook))
|
||||
$paiement->ext_payment_site = $service;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$paiement_id = $paiement->create($user, 0);
|
||||
if ($paiement_id < 0)
|
||||
@ -351,45 +351,45 @@ if (empty($reshook))
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$facture->modelpdf;
|
||||
$model = $facture->modelpdf;
|
||||
$ret = $facture->fetch($facid); // Reload to get new records
|
||||
|
||||
$facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$label='(CustomerInvoicePayment)';
|
||||
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
|
||||
$result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', '');
|
||||
$label = '(CustomerInvoicePayment)';
|
||||
if (GETPOST('type') == 2) $label = '(CustomerInvoicePaymentBack)';
|
||||
$result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', '');
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
elseif (GETPOST('closepaidinvoices')=='on') {
|
||||
elseif (GETPOST('closepaidinvoices') == 'on') {
|
||||
$facture->set_paid($user);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
|
||||
$invoiceid=0;
|
||||
$invoiceid = 0;
|
||||
foreach ($paiement->amounts as $key => $amount)
|
||||
{
|
||||
$facid = $key;
|
||||
if (is_numeric($amount) && $amount <> 0)
|
||||
{
|
||||
if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment
|
||||
else $invoiceid=$facid;
|
||||
if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment
|
||||
else $invoiceid = $facid;
|
||||
}
|
||||
}
|
||||
if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid;
|
||||
@ -417,39 +417,39 @@ $form = new Form($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) {
|
||||
if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
|
||||
$service = 'StripeLive';
|
||||
$servicestatus = 0;
|
||||
} else {
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
|
||||
}
|
||||
|
||||
if (GETPOST('error')){
|
||||
if (GETPOST('error')) {
|
||||
setEventMessages(GETPOST('error'), null, 'errors');
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
$result=$facture->fetch($facid);
|
||||
$result = $facture->fetch($facid);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
$facture->fetch_thirdparty();
|
||||
|
||||
$title='';
|
||||
if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer");
|
||||
if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer");
|
||||
$title = '';
|
||||
if ($facture->type != 2) $title .= $langs->trans("EnterPaymentReceivedFromCustomer");
|
||||
if ($facture->type == 2) $title .= $langs->trans("EnterPaymentDueToCustomer");
|
||||
print load_fiche_titre($title);
|
||||
|
||||
// Initialize data for confirmation (this is used because data can be change during confirmation)
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
$i=0;
|
||||
$i = 0;
|
||||
|
||||
$formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id);
|
||||
$formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid);
|
||||
$formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type);
|
||||
$formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id);
|
||||
$formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid);
|
||||
$formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type);
|
||||
}
|
||||
|
||||
|
||||
@ -544,7 +544,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
';
|
||||
|
||||
print ' });'."\n";
|
||||
if (!empty($conf->use_javascript_ajax)){
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
//Add js for AutoFill
|
||||
print ' $(document).ready(function () {';
|
||||
print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
|
||||
@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
|
||||
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
//$form->select_comptes($accountid,'accountid',0,'',2);
|
||||
print '<input name="accountid" type="hidden" value="'.$conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS.'">';
|
||||
@ -615,7 +615,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
$customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
$customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
|
||||
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
|
||||
@ -632,62 +632,62 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<tr>';
|
||||
|
||||
print '<td class="center" width="20" ';
|
||||
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
|
||||
if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print '><input type="radio" id="source_id" class="flat" name="source_id" value="'.$src->id.'"';
|
||||
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
|
||||
if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) {
|
||||
print ' disabled';
|
||||
} elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) {
|
||||
} elseif (($customerstripe->default_source == $src->id && $action != 'add_paiement') or ($source == $src->id && $action == 'add_paiement')) {
|
||||
print ' checked';
|
||||
}
|
||||
print '></td>';
|
||||
|
||||
print '<td ';
|
||||
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
|
||||
if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
|
||||
print' >';
|
||||
if ($src->object=='card') {
|
||||
if ($src->object == 'card') {
|
||||
print img_credit_card($src->brand);
|
||||
} elseif ($src->object=='source' && $src->type=='card') {
|
||||
} elseif ($src->object == 'source' && $src->type == 'card') {
|
||||
print img_credit_card($src->card->brand);
|
||||
} elseif ($src->object=='source' && $src->type=='sepa_debit') {
|
||||
} elseif ($src->object == 'source' && $src->type == 'sepa_debit') {
|
||||
print '<span class="fa fa-university fa-2x fa-fw"></span>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td ';
|
||||
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
|
||||
if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print' >';
|
||||
if ($src->object=='card') {
|
||||
if ($src->object == 'card') {
|
||||
print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
|
||||
print '</td><td>';
|
||||
if ($src->country) {
|
||||
$img = picto_from_langcode($src->country);
|
||||
print $img?$img.' ':'';
|
||||
print $img ? $img.' ' : '';
|
||||
print getCountry($src->country, 1);
|
||||
} else {
|
||||
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
} elseif ($src->object=='source' && $src->type=='card') {
|
||||
} elseif ($src->object == 'source' && $src->type == 'card') {
|
||||
print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
|
||||
print '</td><td>';
|
||||
if ($src->card->country) {
|
||||
$img = picto_from_langcode($src->card->country);
|
||||
print $img?$img.' ':'';
|
||||
print $img ? $img.' ' : '';
|
||||
print getCountry($src->card->country, 1);
|
||||
} else {
|
||||
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
} elseif ($src->object=='source' && $src->type=='sepa_debit') {
|
||||
} elseif ($src->object == 'source' && $src->type == 'sepa_debit') {
|
||||
print 'info sepa';
|
||||
print '</td><td>';
|
||||
if ($src->sepa_debit->country) {
|
||||
$img = picto_from_langcode($src->sepa_debit->country);
|
||||
print $img?$img.' ':'';
|
||||
print $img ? $img.' ' : '';
|
||||
print getCountry($src->sepa_debit->country, 1);
|
||||
} else {
|
||||
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
@ -696,11 +696,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</td>';
|
||||
// Default
|
||||
print '<td class="center" width="50" ';
|
||||
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
|
||||
if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print'>';
|
||||
if (($customerstripe->default_source==$src->id)) {
|
||||
if (($customerstripe->default_source == $src->id)) {
|
||||
print "<SPAN class=' fa fa-star fa-2x'></SPAN>";
|
||||
}
|
||||
print '</td>';
|
||||
@ -711,32 +711,32 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
// $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid)."");
|
||||
//}
|
||||
|
||||
if (($account->type=='custom' or $account->type=='express') && $entity==1) {
|
||||
if (($account->type == 'custom' or $account->type == 'express') && $entity == 1) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td class="center" width="20" ';
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print'><input type="radio" id="source_id" class="flat" name="source_id" value="'.$conf->global->STRIPE_EXTERNAL_ACCOUNT.'"';
|
||||
if ((empty($input) && $action != 'add_paiement') or ($source==$conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) {
|
||||
if ((empty($input) && $action != 'add_paiement') or ($source == $conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) {
|
||||
print ' checked';
|
||||
} elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) {
|
||||
} elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT != $source) {
|
||||
print ' disabled';
|
||||
}
|
||||
print '></td><td ';
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print '><span class="fa fa-cc-stripe fa-3x fa-fw"></span></td>';
|
||||
|
||||
print '<td ';
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
|
||||
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print'>'.$langs->trans('sold');
|
||||
print'</td><td ';
|
||||
if ($action == 'add_paiement' && $src->id!=$source) {
|
||||
if ($action == 'add_paiement' && $src->id != $source) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print'>';
|
||||
@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</td>';
|
||||
// Default
|
||||
print '<td class="center" width="50" ';
|
||||
if ($action == 'add_paiement' && $src->id!=$source) {
|
||||
if ($action == 'add_paiement' && $src->id != $source) {
|
||||
print'class="opacitymedium"';
|
||||
}
|
||||
print'>';
|
||||
@ -756,7 +756,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) {
|
||||
if (empty($input) && !$stripe->getStripeCustomerAccount($facture->socid)) {
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
|
||||
@ -768,33 +768,33 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
*/
|
||||
|
||||
$sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, ';
|
||||
$sql.= ' f.datef as df, f.fk_soc as socid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql .= ' f.datef as df, f.fk_soc as socid';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
|
||||
if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) {
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)';
|
||||
}
|
||||
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('invoice').")";
|
||||
$sql.= ' AND (f.fk_soc = '.$facture->socid;
|
||||
$sql .= ' WHERE f.entity IN ('.getEntity('invoice').")";
|
||||
$sql .= ' AND (f.fk_soc = '.$facture->socid;
|
||||
|
||||
if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
|
||||
$sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')';
|
||||
$sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')';
|
||||
}
|
||||
|
||||
$sql.= ') AND f.paye = 0';
|
||||
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
|
||||
$sql .= ') AND f.paye = 0';
|
||||
$sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
|
||||
if ($facture->type != 2)
|
||||
{
|
||||
$sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
|
||||
$sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
|
||||
$sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
|
||||
}
|
||||
|
||||
// Sort invoices by date and serial number: the older one comes first
|
||||
$sql.=' ORDER BY f.datef ASC, f.ref ASC';
|
||||
$sql .= ' ORDER BY f.datef ASC, f.ref ASC';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -802,17 +802,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
$sign=1;
|
||||
if ($facture->type == 2) $sign=-1;
|
||||
$sign = 1;
|
||||
if ($facture->type == 2) $sign = -1;
|
||||
|
||||
$arraytitle=$langs->trans('Invoice');
|
||||
if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes");
|
||||
$alreadypayedlabel=$langs->trans('Received');
|
||||
$multicurrencyalreadypayedlabel=$langs->trans('MulticurrencyReceived');
|
||||
if ($facture->type == 2) { $alreadypayedlabel=$langs->trans("PaidBack"); $multicurrencyalreadypayedlabel=$langs->trans("MulticurrencyPaidBack"); }
|
||||
$remaindertopay=$langs->trans('RemainderToTake');
|
||||
$multicurrencyremaindertopay=$langs->trans('MulticurrencyRemainderToTake');
|
||||
if ($facture->type == 2) { $remaindertopay=$langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay=$langs->trans("MulticurrencyRemainderToPayBack"); }
|
||||
$arraytitle = $langs->trans('Invoice');
|
||||
if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes");
|
||||
$alreadypayedlabel = $langs->trans('Received');
|
||||
$multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived');
|
||||
if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); }
|
||||
$remaindertopay = $langs->trans('RemainderToTake');
|
||||
$multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake');
|
||||
if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); }
|
||||
|
||||
$i = 0;
|
||||
|
||||
@ -838,17 +838,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
|
||||
}
|
||||
|
||||
$tmpinvoice =new Facture($db);
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook
|
||||
$tmpinvoice = new Facture($db);
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '<td align="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$total=0;
|
||||
$totalrecu=0;
|
||||
$totalrecucreditnote=0;
|
||||
$totalrecudeposits=0;
|
||||
$total = 0;
|
||||
$totalrecu = 0;
|
||||
$totalrecucreditnote = 0;
|
||||
$totalrecudeposits = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
@ -857,29 +857,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($objp->socid);
|
||||
|
||||
$invoice=new Facture($db);
|
||||
$invoice = new Facture($db);
|
||||
$invoice->fetch($objp->facid);
|
||||
$paiement = $invoice->getSommePaiement();
|
||||
$creditnotes=$invoice->getSumCreditNotesUsed();
|
||||
$deposits=$invoice->getSumDepositsUsed();
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT');
|
||||
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
|
||||
$creditnotes = $invoice->getSumCreditNotesUsed();
|
||||
$deposits = $invoice->getSumDepositsUsed();
|
||||
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
|
||||
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
|
||||
|
||||
// Multicurrency Price
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
$multicurrency_payment = $invoice->getSommePaiement(1);
|
||||
$multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1);
|
||||
$multicurrency_deposits=$invoice->getSumDepositsUsed(1);
|
||||
$multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
|
||||
$multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
|
||||
$multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
|
||||
$multicurrency_deposits = $invoice->getSumDepositsUsed(1);
|
||||
$multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
|
||||
$multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td>';
|
||||
print $invoice->getNomUrl(1, '');
|
||||
if($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' ';
|
||||
if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' ';
|
||||
print "</td>\n";
|
||||
|
||||
// Date
|
||||
@ -946,7 +946,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print "</td>";
|
||||
|
||||
// Multicurrency Price
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<td class="right">';
|
||||
|
||||
@ -972,8 +972,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
// Warning
|
||||
print '<td class="center" width="16">';
|
||||
@ -987,16 +987,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$paiement;
|
||||
$totalrecucreditnote+=$creditnotes;
|
||||
$totalrecudeposits+=$deposits;
|
||||
$total += $objp->total;
|
||||
$total_ttc += $objp->total_ttc;
|
||||
$totalrecu += $paiement;
|
||||
$totalrecucreditnote += $creditnotes;
|
||||
$totalrecudeposits += $deposits;
|
||||
$i++;
|
||||
}
|
||||
if ($i > 1)
|
||||
{
|
||||
$amount=round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT'))*100);
|
||||
$amount = round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) * 100);
|
||||
|
||||
// Print total
|
||||
print '<tr class="liste_total">';
|
||||
@ -1033,10 +1033,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
// Bouton Enregistrer
|
||||
if ($action != 'add_paiement')
|
||||
{
|
||||
$checkboxlabel=$langs->trans("ClosePaidInvoicesAutomatically");
|
||||
if ($facture->type == 2) $checkboxlabel=$langs->trans("ClosePaidCreditNotesAutomatically");
|
||||
$buttontitle=$langs->trans('ToMakePayment');
|
||||
if ($facture->type == 2) $buttontitle=$langs->trans('ToMakePaymentBack');
|
||||
$checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
|
||||
if ($facture->type == 2) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
|
||||
$buttontitle = $langs->trans('ToMakePayment');
|
||||
if ($facture->type == 2) $buttontitle = $langs->trans('ToMakePaymentBack');
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
|
||||
@ -1052,18 +1052,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
// Form to confirm payment
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
$preselectedchoice=$addwarning?'no':'yes';
|
||||
$preselectedchoice = $addwarning ? 'no' : 'yes';
|
||||
|
||||
print '<br>';
|
||||
if (!empty($totalpayment)) {
|
||||
$text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency));
|
||||
}
|
||||
if (!empty($multicurrency_totalpayment)) {
|
||||
$text.='<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency"));
|
||||
$text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency"));
|
||||
}
|
||||
if (GETPOST('closepaidinvoices'))
|
||||
{
|
||||
$text.='<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
|
||||
$text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
|
||||
print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
|
||||
}
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
|
||||
@ -1078,27 +1078,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
* Show list of payments
|
||||
*/
|
||||
|
||||
if (! GETPOST('action'))
|
||||
if (!GETPOST('action'))
|
||||
{
|
||||
if ($page == -1 || empty($page)) $page = 0 ;
|
||||
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
if ($page == -1 || empty($page)) $page = 0;
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$offset = $limit * $page;
|
||||
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
if (! $sortfield) $sortfield='p.datep';
|
||||
if (!$sortorder) $sortorder = 'DESC';
|
||||
if (!$sortfield) $sortfield = 'p.datep';
|
||||
|
||||
$sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref';
|
||||
$sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c';
|
||||
$sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').")";
|
||||
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c';
|
||||
$sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id';
|
||||
$sql .= ' AND f.entity IN ('.getEntity('invoice').")";
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= ' AND f.fk_soc = '.$socid;
|
||||
$sql .= ' AND f.fk_soc = '.$socid;
|
||||
}
|
||||
|
||||
$sql.= ' ORDER BY '.$sortfield.' '.$sortorder;
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
@ -1115,8 +1115,8 @@ if (! GETPOST('action'))
|
||||
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
|
||||
$tmpobject = new Paiement($db);
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
@ -1131,8 +1131,8 @@ if (! GETPOST('action'))
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
||||
print '<td class="right">'.price($objp->amount).'</td>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -77,25 +77,25 @@ $stripeacc = $stripe->getStripeAccount($service);
|
||||
print $langs->trans('ErrorStripeAccountNotDefined');
|
||||
}*/
|
||||
|
||||
if (! $rowid) {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
if (!$rowid) {
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
|
||||
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
|
||||
print '<input type="hidden" name="page" value="' . $page . '">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
$title=$langs->trans("StripePayoutList");
|
||||
$title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)');
|
||||
$title = $langs->trans("StripePayoutList");
|
||||
$title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
|
||||
|
||||
@ -77,24 +77,24 @@ $stripeacc = $stripe->getStripeAccount($service);
|
||||
print $langs->trans('ErrorStripeAccountNotDefined');
|
||||
}*/
|
||||
|
||||
if (! $rowid) {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
if (!$rowid) {
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '')
|
||||
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
|
||||
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
|
||||
print '<input type="hidden" name="page" value="' . $page . '">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
$title=$langs->trans("StripeTransactionList");
|
||||
$title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)');
|
||||
$title = $langs->trans("StripeTransactionList");
|
||||
$title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
|
||||
|
||||
@ -25,37 +25,37 @@
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
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.'/categories/class/categorie.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.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 Ba or Restaurant
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$setterminal = GETPOST('setterminal', 'int');
|
||||
|
||||
if ($setterminal>0)
|
||||
if ($setterminal > 0)
|
||||
{
|
||||
$_SESSION["takeposterminal"]=$setterminal;
|
||||
$_SESSION["takeposterminal"] = $setterminal;
|
||||
}
|
||||
|
||||
$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter"));
|
||||
$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter"));
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
// Title
|
||||
$title='TakePOS - Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
|
||||
$head='<meta name="apple-mobile-web-app-title" content="TakePOS"/>
|
||||
$title = 'TakePOS - Dolibarr '.DOL_VERSION;
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
|
||||
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
|
||||
@ -66,14 +66,14 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
|
||||
<script language="javascript">
|
||||
<?php
|
||||
$categorie = new Categorie($db);
|
||||
$categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0), 1);
|
||||
$categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
|
||||
|
||||
// Search root category to know its level
|
||||
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
|
||||
$levelofrootcategory=0;
|
||||
$levelofrootcategory = 0;
|
||||
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
|
||||
{
|
||||
foreach($categories as $key => $categorycursor)
|
||||
foreach ($categories as $key => $categorycursor)
|
||||
{
|
||||
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
|
||||
{
|
||||
@ -86,7 +86,7 @@ $levelofmaincategories = $levelofrootcategory + 1;
|
||||
|
||||
$maincategories = array();
|
||||
$subcategories = array();
|
||||
foreach($categories as $key => $categorycursor)
|
||||
foreach ($categories as $key => $categorycursor)
|
||||
{
|
||||
if ($categorycursor['level'] == $levelofmaincategories)
|
||||
{
|
||||
@ -111,7 +111,7 @@ var currentcat;
|
||||
var pageproducts=0;
|
||||
var pagecategories=0;
|
||||
var pageactions=0;
|
||||
var place="<?php echo $place;?>";
|
||||
var place="<?php echo $place; ?>";
|
||||
var editaction="qty";
|
||||
var editnumber="";
|
||||
|
||||
@ -166,14 +166,14 @@ function Exit(){
|
||||
|
||||
<body style="overflow: hidden; background-color:#D1D1D1;">
|
||||
<?php
|
||||
if ($conf->global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print '<div id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
|
||||
if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '<div id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
|
||||
?>
|
||||
<div class="container">
|
||||
<div class="phonebuttonsrow">
|
||||
<button type="button" class="phonebutton" onclick="LoadPlacesList();"><?php echo strtoupper(substr($langs->trans('Floors'), 0, 3));?></button>
|
||||
<button type="button" class="phonebutton" onclick="LoadCats();"><?php echo strtoupper(substr($langs->trans('Categories'), 0, 3));?></button>
|
||||
<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();"><?php echo strtoupper(substr($langs->trans('Order'), 0, 3));?></button>
|
||||
<button type="button" class="phonebutton" onclick="Exit();"><?php echo strtoupper(substr($langs->trans('Logout'), 0, 3));?></button>
|
||||
<button type="button" class="phonebutton" onclick="LoadPlacesList();"><?php echo strtoupper(substr($langs->trans('Floors'), 0, 3)); ?></button>
|
||||
<button type="button" class="phonebutton" onclick="LoadCats();"><?php echo strtoupper(substr($langs->trans('Categories'), 0, 3)); ?></button>
|
||||
<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();"><?php echo strtoupper(substr($langs->trans('Order'), 0, 3)); ?></button>
|
||||
<button type="button" class="phonebutton" onclick="Exit();"><?php echo strtoupper(substr($langs->trans('Logout'), 0, 3)); ?></button>
|
||||
</div>
|
||||
<div class="row1">
|
||||
<div id="phonediv1" class="phonediv1"></div>
|
||||
|
||||
@ -23,27 +23,27 @@
|
||||
* \brief Page to ask a new password
|
||||
*/
|
||||
|
||||
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
||||
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
|
||||
if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
|
||||
|
||||
// Load translation files required by page
|
||||
$langs->loadLangs(array('errors', 'users', 'companies', 'ldap', 'other'));
|
||||
|
||||
// Security check
|
||||
if (! empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
|
||||
if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/');
|
||||
exit;
|
||||
}
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$mode=$dolibarr_main_authentication;
|
||||
if (! $mode) $mode='http';
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$mode = $dolibarr_main_authentication;
|
||||
if (!$mode) $mode = 'http';
|
||||
|
||||
$username = trim(GETPOST('username', 'alpha'));
|
||||
$passwordhash = trim(GETPOST('passwordhash', 'alpha'));
|
||||
@ -53,11 +53,11 @@ $conf->entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : 1);
|
||||
$hookmanager->initHooks(array('passwordforgottenpage'));
|
||||
|
||||
|
||||
if (GETPOST('dol_hide_leftmenu', 'alpha') || ! empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu=1;
|
||||
if (GETPOST('dol_hide_topmenu', 'alpha') || ! empty($_SESSION['dol_hide_topmenu'])) $conf->dol_hide_topmenu=1;
|
||||
if (GETPOST('dol_optimize_smallscreen', 'alpha') || ! empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen=1;
|
||||
if (GETPOST('dol_no_mouse_hover', 'alpha') || ! empty($_SESSION['dol_no_mouse_hover'])) $conf->dol_no_mouse_hover=1;
|
||||
if (GETPOST('dol_use_jmobile', 'alpha') || ! empty($_SESSION['dol_use_jmobile'])) $conf->dol_use_jmobile=1;
|
||||
if (GETPOST('dol_hide_leftmenu', 'alpha') || !empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu = 1;
|
||||
if (GETPOST('dol_hide_topmenu', 'alpha') || !empty($_SESSION['dol_hide_topmenu'])) $conf->dol_hide_topmenu = 1;
|
||||
if (GETPOST('dol_optimize_smallscreen', 'alpha') || !empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen = 1;
|
||||
if (GETPOST('dol_no_mouse_hover', 'alpha') || !empty($_SESSION['dol_no_mouse_hover'])) $conf->dol_no_mouse_hover = 1;
|
||||
if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) $conf->dol_use_jmobile = 1;
|
||||
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ if (GETPOST('dol_use_jmobile', 'alpha') || ! empty($_SESSION['dol_use_jmobile'])
|
||||
if ($action == 'validatenewpassword' && $username && $passwordhash)
|
||||
{
|
||||
$edituser = new User($db);
|
||||
$result=$edituser->fetch('', $_GET["username"]);
|
||||
$result = $edituser->fetch('', $_GET["username"]);
|
||||
if ($result < 0)
|
||||
{
|
||||
$message = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists", $username).'</div>';
|
||||
@ -77,7 +77,7 @@ if ($action == 'validatenewpassword' && $username && $passwordhash)
|
||||
{
|
||||
if (dol_verifyHash($edituser->pass_temp, $passwordhash))
|
||||
{
|
||||
$newpassword=$edituser->setPassword($user, $edituser->pass_temp, 0);
|
||||
$newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
|
||||
dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database");
|
||||
header("Location: ".DOL_URL_ROOT.'/');
|
||||
exit;
|
||||
@ -93,36 +93,36 @@ if ($action == 'validatenewpassword' && $username && $passwordhash)
|
||||
if ($action == 'buildnewpassword' && $username)
|
||||
{
|
||||
$sessionkey = 'dol_antispam_value';
|
||||
$ok=(array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
|
||||
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
|
||||
|
||||
// Verify code
|
||||
if (! $ok)
|
||||
if (!$ok)
|
||||
{
|
||||
$message = '<div class="error">'.$langs->trans("ErrorBadValueForCode").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$edituser = new User($db);
|
||||
$result=$edituser->fetch('', $username, '', 1);
|
||||
$result = $edituser->fetch('', $username, '', 1);
|
||||
if ($result == 0 && preg_match('/@/', $username))
|
||||
{
|
||||
$result=$edituser->fetch('', '', '', 1, -1, $username);
|
||||
$result = $edituser->fetch('', '', '', 1, -1, $username);
|
||||
}
|
||||
|
||||
if ($result <= 0 && $edituser->error == 'USERNOTFOUND')
|
||||
{
|
||||
$message = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists", $username).'</div>';
|
||||
$username='';
|
||||
$username = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $edituser->email)
|
||||
if (!$edituser->email)
|
||||
{
|
||||
$message = '<div class="error">'.$langs->trans("ErrorLoginHasNoEmail").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$newpassword=$edituser->setPassword($user, '', 1);
|
||||
$newpassword = $edituser->setPassword($user, '', 1);
|
||||
if ($newpassword < 0)
|
||||
{
|
||||
// Failed
|
||||
@ -134,11 +134,11 @@ if ($action == 'buildnewpassword' && $username)
|
||||
if ($edituser->send_password($edituser, $newpassword, 1) > 0)
|
||||
{
|
||||
$message = '<div class="ok">'.$langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)).'</div>';
|
||||
$username='';
|
||||
$username = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message.= '<div class="error">'.$edituser->error.'</div>';
|
||||
$message .= '<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,8 +154,8 @@ if ($action == 'buildnewpassword' && $username)
|
||||
$dol_url_root = DOL_URL_ROOT;
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
$title = 'Dolibarr '.DOL_VERSION;
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
// Select templates
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php"))
|
||||
@ -167,55 +167,55 @@ else
|
||||
$template_dir = DOL_DOCUMENT_ROOT."/core/tpl/";
|
||||
}
|
||||
|
||||
if (! $username) $focus_element = 'username';
|
||||
if (!$username) $focus_element = 'username';
|
||||
else $focus_element = 'password';
|
||||
|
||||
// Send password button enabled ?
|
||||
$disabled='disabled';
|
||||
if (preg_match('/dolibarr/i', $mode)) $disabled='';
|
||||
if (! empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled=''; // To force button enabled
|
||||
$disabled = 'disabled';
|
||||
if (preg_match('/dolibarr/i', $mode)) $disabled = '';
|
||||
if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled = ''; // To force button enabled
|
||||
|
||||
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
||||
$width=0;
|
||||
$rowspan=2;
|
||||
$urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
|
||||
if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
|
||||
$width = 0;
|
||||
$rowspan = 2;
|
||||
$urllogo = DOL_URL_ROOT.'/theme/login_logo.png';
|
||||
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
|
||||
}
|
||||
elseif (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
|
||||
elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
|
||||
$width=128;
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
|
||||
$width = 128;
|
||||
}
|
||||
elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png';
|
||||
$urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png';
|
||||
}
|
||||
elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png'))
|
||||
{
|
||||
$urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
|
||||
$urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png';
|
||||
}
|
||||
|
||||
// Security graphical code
|
||||
if (function_exists("imagecreatefrompng") && ! $disabled)
|
||||
if (function_exists("imagecreatefrompng") && !$disabled)
|
||||
{
|
||||
$captcha = 1;
|
||||
$captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
|
||||
}
|
||||
|
||||
// Execute hook getPasswordForgottenPageOptions (for table)
|
||||
$parameters=array('entity' => GETPOST('entity', 'int'));
|
||||
$hookmanager->executeHooks('getPasswordForgottenPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks
|
||||
if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) {
|
||||
$parameters = array('entity' => GETPOST('entity', 'int'));
|
||||
$hookmanager->executeHooks('getPasswordForgottenPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks
|
||||
if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
|
||||
$morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility
|
||||
} else {
|
||||
$morelogincontent = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
// Execute hook getPasswordForgottenPageExtraOptions (eg for js)
|
||||
$parameters=array('entity' => GETPOST('entity', 'int'));
|
||||
$reshook = $hookmanager->executeHooks('getPasswordForgottenPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
$parameters = array('entity' => GETPOST('entity', 'int'));
|
||||
$reshook = $hookmanager->executeHooks('getPasswordForgottenPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
$moreloginextracontent = $hookmanager->resPrint;
|
||||
|
||||
include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP
|
||||
include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP
|
||||
|
||||
@ -41,7 +41,7 @@ if ($object->fetch($id) < 1) {
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel) $action='';
|
||||
if ($cancel) $action = '';
|
||||
|
||||
if ($_POST) {
|
||||
if ($action == 'edit') {
|
||||
@ -71,7 +71,7 @@ if ($_POST) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
if ($objectval->update($user) > 0) {
|
||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||
@ -131,7 +131,7 @@ llxHeader('', $title);
|
||||
|
||||
//print load_fiche_titre($title);
|
||||
|
||||
$h=0;
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/variants/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'variant';
|
||||
|
||||
@ -35,17 +35,17 @@ $price_impact = GETPOST('price_impact', 'alpha');
|
||||
$price_impact_percent = (bool) GETPOST('price_impact_percent');
|
||||
$form = new Form($db);
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$massaction=GETPOST('massaction', 'alpha');
|
||||
$show_files=GETPOST('show_files', 'int');
|
||||
$confirm=GETPOST('confirm', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$massaction = GETPOST('massaction', 'alpha');
|
||||
$show_files = GETPOST('show_files', 'int');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
|
||||
// Security check
|
||||
$fieldvalue = (! empty($id) ? $id : $ref);
|
||||
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
|
||||
$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
|
||||
$fieldvalue = (!empty($id) ? $id : $ref);
|
||||
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
|
||||
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
|
||||
|
||||
$prodstatic = new Product($db);
|
||||
$prodattr = new ProductAttribute($db);
|
||||
@ -65,12 +65,12 @@ $selectedvariant = $_SESSION['addvariant_'.$object->id];
|
||||
*/
|
||||
|
||||
if ($cancel) {
|
||||
$action='';
|
||||
$massactions='';
|
||||
$action = '';
|
||||
$massactions = '';
|
||||
unset($_SESSION['addvariant_'.$object->id]);
|
||||
}
|
||||
|
||||
if (! $object->isProduct() && ! $object->isService()) {
|
||||
if (!$object->isProduct() && !$object->isService()) {
|
||||
header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2));
|
||||
exit();
|
||||
}
|
||||
@ -84,8 +84,8 @@ if ($action == 'create' && GETPOST('selectvariant', 'alpha')) // We click on sel
|
||||
$action = 'add';
|
||||
if (GETPOST('attribute') != '-1' && GETPOST('value') != '-1')
|
||||
{
|
||||
$selectedvariant[GETPOST('attribute').':'.GETPOST('value')]=GETPOST('attribute').':'.GETPOST('value');
|
||||
$_SESSION['addvariant_'.$object->id]=$selectedvariant;
|
||||
$selectedvariant[GETPOST('attribute').':'.GETPOST('value')] = GETPOST('attribute').':'.GETPOST('value');
|
||||
$_SESSION['addvariant_'.$object->id] = $selectedvariant;
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ $prodcomb2val = new ProductCombination2ValuePair($db);
|
||||
$productCombination2ValuePairs1 = array();
|
||||
|
||||
if ($_POST) {
|
||||
if (($action == 'add' || $action == 'create') && empty($massaction) && ! GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations
|
||||
if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations
|
||||
{
|
||||
//$features = GETPOST('features', 'array');
|
||||
$features = $_SESSION['addvariant_'.$object->id];
|
||||
@ -139,7 +139,7 @@ if ($_POST) {
|
||||
//var_dump($sanit_features);
|
||||
//var_dump($productCombination2ValuePairs1); exit;
|
||||
|
||||
if (! $prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features))
|
||||
if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features))
|
||||
{
|
||||
$result = $prodcomb->createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact);
|
||||
if ($result > 0)
|
||||
@ -161,7 +161,7 @@ if ($_POST) {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
elseif (! empty($massaction))
|
||||
elseif (!empty($massaction))
|
||||
{
|
||||
$bulkaction = $massaction;
|
||||
$error = 0;
|
||||
@ -312,14 +312,14 @@ if (! empty($id) || ! empty($ref))
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
|
||||
// TVA
|
||||
print '<tr><td class="titlefield">' . $langs->trans("DefaultTaxRate") . '</td><td>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>';
|
||||
|
||||
$positiverates='';
|
||||
if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx);
|
||||
if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx);
|
||||
if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx);
|
||||
if (empty($positiverates)) $positiverates='0';
|
||||
echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr);
|
||||
$positiverates = '';
|
||||
if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx);
|
||||
if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx);
|
||||
if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx);
|
||||
if (empty($positiverates)) $positiverates = '0';
|
||||
echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr);
|
||||
/*
|
||||
if ($object->default_vat_code)
|
||||
{
|
||||
@ -329,20 +329,20 @@ if (! empty($id) || ! empty($ref))
|
||||
print '</td></tr>';
|
||||
|
||||
// Price
|
||||
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
|
||||
if ($object->price_base_type == 'TTC') {
|
||||
print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type);
|
||||
print price($object->price_ttc).' '.$langs->trans($object->price_base_type);
|
||||
} else {
|
||||
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
|
||||
print price($object->price).' '.$langs->trans($object->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Price minimum
|
||||
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
|
||||
if ($object->price_base_type == 'TTC') {
|
||||
print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type);
|
||||
print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type);
|
||||
} else {
|
||||
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
|
||||
print price($object->price_min).' '.$langs->trans($object->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -378,7 +378,7 @@ if (! empty($id) || ! empty($ref))
|
||||
$features = $_SESSION['addvariant_'.$object->id];
|
||||
//First, sanitize
|
||||
$listofvariantselected = '<div id="parttoaddvariant">';
|
||||
if (! empty($features)) {
|
||||
if (!empty($features)) {
|
||||
foreach ($features as $feature) {
|
||||
$explode = explode(':', $feature);
|
||||
|
||||
@ -390,7 +390,7 @@ if (! empty($id) || ! empty($ref))
|
||||
continue;
|
||||
}
|
||||
|
||||
$listofvariantselected .= '<i>' . $prodattr->label . '</i>:'. $prodattr_val->value . ' ';
|
||||
$listofvariantselected .= '<i>'.$prodattr->label.'</i>:'.$prodattr_val->value.' ';
|
||||
}
|
||||
}
|
||||
$listofvariantselected .= '</div>';
|
||||
@ -535,7 +535,7 @@ if (! empty($id) || ! empty($ref))
|
||||
<option value="-1"> </option>
|
||||
</select>
|
||||
<?php
|
||||
$htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
|
||||
$htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
/*
|
||||
print ' <a href="'.DOL_URL_ROOT.'/variants/create.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=add&id='.$object->id).'">';
|
||||
@ -573,7 +573,7 @@ if (! empty($id) || ! empty($ref))
|
||||
$result2 = $prodattr_val->fetch($val->fk_prod_attr_val);
|
||||
if ($result1 > 0 && $result2 > 0)
|
||||
{
|
||||
print $prodattr->label . ' - '.$prodattr_val->value.'<br>';
|
||||
print $prodattr->label.' - '.$prodattr_val->value.'<br>';
|
||||
// TODO Add delete link
|
||||
}
|
||||
}
|
||||
@ -606,7 +606,7 @@ if (! empty($id) || ! empty($ref))
|
||||
?>
|
||||
|
||||
<div style="text-align: center">
|
||||
<input type="submit" name="create" <?php if (! is_array($productCombination2ValuePairs1)) print ' disabled="disabled"'; ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans('Save') ?>" class="button">
|
||||
<input type="submit" name="create" <?php if (!is_array($productCombination2ValuePairs1)) print ' disabled="disabled"'; ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans('Save') ?>" class="button">
|
||||
|
||||
<input type="submit" name="cancel" value="<?php echo $langs->trans('Cancel'); ?>" class="button">
|
||||
</div>
|
||||
@ -687,7 +687,7 @@ if (! empty($id) || ! empty($ref))
|
||||
|
||||
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
|
||||
// List of variants
|
||||
@ -708,7 +708,7 @@ if (! empty($id) || ! empty($ref))
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
*/
|
||||
|
||||
$aaa='';
|
||||
$aaa = '';
|
||||
if (count($productCombinations))
|
||||
{
|
||||
$aaa = '<label for="massaction">'.$langs->trans('BulkActions').'</label>';
|
||||
@ -741,7 +741,7 @@ if (! empty($id) || ! empty($ref))
|
||||
<td class="liste_titre"></td>
|
||||
<?php
|
||||
print '<td class="liste_titre center">';
|
||||
$searchpicto=$form->showCheckAddButtons('checkforselect', 1);
|
||||
$searchpicto = $form->showCheckAddButtons('checkforselect', 1);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user