mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 10:52:37 +01:00
Merge branch 'develop' into RestAPI
This commit is contained in:
@@ -325,18 +325,21 @@ script:
|
||||
set +e
|
||||
echo
|
||||
#cat $TRAVIS_BUILD_DIR/upgrade400500-2.log
|
||||
#cat $TRAVIS_BUILD_DIR/upgrade500600.log
|
||||
#cat $TRAVIS_BUILD_DIR/upgrade500600-2.log
|
||||
#cat $TRAVIS_BUILD_DIR/upgrade500600-3.log
|
||||
#cat /tmp/dolibarr_install.log
|
||||
|
||||
- |
|
||||
echo "Unit testing"
|
||||
# Ensure we catch errors. Set this to +e if you want to go to the end to see log file.
|
||||
# Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
|
||||
set -e
|
||||
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php
|
||||
set +e
|
||||
|
||||
- |
|
||||
#echo "Output dolibarr.log"
|
||||
#echo cat documents/dolibarr.log
|
||||
#cat documents/dolibarr.log
|
||||
|
||||
after_script:
|
||||
- |
|
||||
|
||||
@@ -16,6 +16,10 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__,
|
||||
__PROPALREF__, ...)
|
||||
* Some REST API to access the dictionary (country, town, ...) were moved into a common API.
|
||||
* Page bank/index.php and bank/bankentries.php were renamed into bank/list.php and bank/bankentries_list.php to
|
||||
follow page naming conventions (so default filter/sort order features can also work).
|
||||
* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed ORDER_SUPPLIER_STATUS_ORDERED
|
||||
* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.1 compared to 6.0.* *****
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
/**
|
||||
* \file dev/initdata/import-thirdparties.php
|
||||
* \brief Script example to insert thirdparties from a csv file.
|
||||
* \brief Script example to insert thirdparties from a csv file.
|
||||
* To purge data, you can have a look at purge-data.php
|
||||
*/
|
||||
|
||||
@@ -123,15 +123,15 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
if ($endlinenb && $i > $endlinenb) continue;
|
||||
|
||||
$nboflines++;
|
||||
|
||||
|
||||
$object = new Societe($db);
|
||||
$object->state = $fields[6];
|
||||
$object->client = $fields[7];
|
||||
$object->fournisseur = $fields[8];
|
||||
|
||||
|
||||
$object->name = $fields[13]?trim($fields[13]):$fields[0];
|
||||
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
|
||||
|
||||
|
||||
$object->address = trim($fields[14]);
|
||||
$object->zip = trim($fields[15]);
|
||||
$object->town = trim($fields[16]);
|
||||
@@ -149,7 +149,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
$condpayment = trim($fields[36]);
|
||||
if ($condpayment == 'A la commande') $condpayment = 'A réception de commande';
|
||||
if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture';
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid');
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
|
||||
if (empty($object->cond_reglement_id))
|
||||
{
|
||||
print " - Error cant find payment mode for ".$condpayment."\n";
|
||||
@@ -166,7 +166,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
// Set price level
|
||||
$object->price_level = 1;
|
||||
if ($labeltype == 'Revendeur') $object->price_level = 2;
|
||||
|
||||
|
||||
print "Process line nb ".$i.", name ".$object->name;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
print " - Creation OK with name ".$object->name." - id = ".$ret;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
if (! $errorrecord && $fields[3])
|
||||
{
|
||||
$salesrep=new User($db);
|
||||
|
||||
|
||||
$tmp=explode(' ',$fields[3],2);
|
||||
$salesrep->firstname = trim($tmp[0]);
|
||||
$salesrep->lastname = trim($tmp[1]);
|
||||
@@ -206,7 +206,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
else $salesrep->login=strtolower($salesrep->firstname);
|
||||
$salesrep->login=preg_replace('/ /','',$salesrep->login);
|
||||
$salesrep->fetch(0,$salesrep->login);
|
||||
|
||||
|
||||
$result = $object->add_commercial($user, $salesrep->id);
|
||||
if ($result < 0)
|
||||
{
|
||||
@@ -217,14 +217,14 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
{
|
||||
print " - create link sale representative OK";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dol_syslog("Add invoice contacts");
|
||||
// Insert an invoice contact if there is an invoice email != standard email
|
||||
if (! $errorrecord && $fields[27] && $fields[26] != $fields[27])
|
||||
{
|
||||
$ret1=$ret2=0;
|
||||
|
||||
|
||||
$contact = new Contact($db);
|
||||
$contact->lastname = $object->name;
|
||||
$contact->address=$object->address;
|
||||
@@ -233,7 +233,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
$contact->country_id=$object->country_id;
|
||||
$contact->email=$fields[27];
|
||||
$contact->socid=$object->id;
|
||||
|
||||
|
||||
$ret1=$contact->create($user);
|
||||
if ($ret1 > 0)
|
||||
{
|
||||
@@ -244,18 +244,18 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
print " - create contact OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dol_syslog("Add delivery contacts");
|
||||
// Insert a delivery contact
|
||||
if (! $errorrecord && $fields[47])
|
||||
{
|
||||
$ret1=$ret2=0;
|
||||
|
||||
|
||||
$contact2 = new Contact($db);
|
||||
$contact2->lastname = 'Service livraison - '.$fields[47];
|
||||
$contact2->address = $fields[48];
|
||||
@@ -264,10 +264,10 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
|
||||
$contact2->note_public=$fields[54];
|
||||
$contact2->socid=$object->id;
|
||||
|
||||
|
||||
// Extrafields
|
||||
$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
|
||||
|
||||
|
||||
$ret1=$contact2->create($user);
|
||||
if ($ret1 > 0)
|
||||
{
|
||||
@@ -278,16 +278,16 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
print " - create contact OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord)
|
||||
|
||||
if ($errorrecord)
|
||||
{
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
|
||||
1
dev/resources/iso-normes/code_nace.txt
Normal file
1
dev/resources/iso-normes/code_nace.txt
Normal file
@@ -0,0 +1 @@
|
||||
http://ec.europa.eu/eurostat/ramon/nomenclatures/index.cfm?TargetUrl=LST_CLS_DLD&StrNom=NACE_REV2&StrLanguageCode=FR&StrLayoutCode=#
|
||||
@@ -126,7 +126,7 @@
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity">
|
||||
<properties>
|
||||
<property name="complexity" value="120" />
|
||||
<property name="absoluteComplexity" value="250" />
|
||||
<property name="absoluteComplexity" value="300" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.Metrics.NestingLevel">
|
||||
|
||||
@@ -15,7 +15,7 @@ then
|
||||
echo "This push local files to transifex for project $project."
|
||||
echo "Note: If you push a language file (not source), file will be skipped if transifex file is newer."
|
||||
echo " Using -f will overwrite translation but not memory."
|
||||
echo "Usage: ./dev/translation/txpush.sh (source|xx_XX|all) [-r dolibarr.file] [-f] [--no-interactive]"
|
||||
echo "Usage: ./dev/translation/txpush.sh (source|xx_XX|all) [-r ".$project.".file] [-f] [--no-interactive]"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -128,8 +128,8 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,
|
||||
|
||||
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
|
||||
$elementList = array();
|
||||
// Must match ids defined into eldy.lib.php
|
||||
$sourceList = array(
|
||||
// Must match ids defined into eldy.lib.php
|
||||
$sourceList = array(
|
||||
'1' => $langs->trans('AccountingJournalType1'),
|
||||
'2' => $langs->trans('AccountingJournalType2'),
|
||||
'3' => $langs->trans('AccountingJournalType3'),
|
||||
@@ -144,216 +144,217 @@ $elementList = array();
|
||||
|
||||
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
|
||||
{
|
||||
$search_country_id = '';
|
||||
$search_country_id = '';
|
||||
}
|
||||
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
{
|
||||
$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;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
// Check that all fields are filled
|
||||
$ok=1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'nature') $fieldnamekey = 'Nature';
|
||||
}
|
||||
// Other checks
|
||||
if (isset($_POST["code"]))
|
||||
{
|
||||
if ($_POST["code"]=='0')
|
||||
{
|
||||
$ok=0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
|
||||
}
|
||||
// Other checks
|
||||
if (isset($_POST["code"]))
|
||||
{
|
||||
if ($_POST["code"]=='0')
|
||||
{
|
||||
$ok=0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
|
||||
{
|
||||
$ok = 0;
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // 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'))
|
||||
{
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
// Recupere id libre pour insertion
|
||||
$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);
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd'))
|
||||
{
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
// Recupere id libre pour insertion
|
||||
$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);
|
||||
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// 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(";
|
||||
// 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(";
|
||||
|
||||
// List of values
|
||||
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] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.=",1)";
|
||||
// List of values
|
||||
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] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
|
||||
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
$i++;
|
||||
}
|
||||
$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
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify'))
|
||||
{
|
||||
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))
|
||||
{
|
||||
$sql.= $tabrowid[$id]."=";
|
||||
$sql.= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
{
|
||||
if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
|
||||
}
|
||||
else if ($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]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
|
||||
{
|
||||
$sql.= $tabrowid[$id]."=";
|
||||
$sql.= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
{
|
||||
if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
|
||||
}
|
||||
else if ($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]])."'";
|
||||
$i++;
|
||||
}
|
||||
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
}
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
}
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
|
||||
if (GETPOST('actioncancel'))
|
||||
{
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
|
||||
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 = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
|
||||
}
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// 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."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
|
||||
}
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@@ -367,8 +368,8 @@ $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);
|
||||
@@ -377,7 +378,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);
|
||||
|
||||
@@ -386,315 +387,315 @@ if ($action == 'delete')
|
||||
*/
|
||||
if ($id)
|
||||
{
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql=$tabsql[$id];
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql=$tabsql[$id];
|
||||
|
||||
if ($search_country_id > 0)
|
||||
{
|
||||
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
|
||||
else $sql.=" WHERE ";
|
||||
$sql.= " c.rowid = ".$search_country_id;
|
||||
}
|
||||
if ($search_country_id > 0)
|
||||
{
|
||||
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
|
||||
else $sql.=" WHERE ";
|
||||
$sql.= " c.rowid = ".$search_country_id;
|
||||
}
|
||||
|
||||
if ($sortfield)
|
||||
{
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield='country_code';
|
||||
$sql.= " ORDER BY ".$sortfield;
|
||||
if ($sortorder)
|
||||
{
|
||||
$sql.=" ".strtoupper($sortorder);
|
||||
}
|
||||
$sql.=", ";
|
||||
// Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
|
||||
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
|
||||
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
|
||||
}
|
||||
else {
|
||||
$sql.=" ORDER BY ";
|
||||
}
|
||||
$sql.=$tabsqlsort[$id];
|
||||
$sql.=$db->plimit($listlimit+1,$offset);
|
||||
//print $sql;
|
||||
if ($sortfield)
|
||||
{
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield='country_code';
|
||||
$sql.= " ORDER BY ".$sortfield;
|
||||
if ($sortorder)
|
||||
{
|
||||
$sql.=" ".strtoupper($sortorder);
|
||||
}
|
||||
$sql.=", ";
|
||||
// Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
|
||||
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
|
||||
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
|
||||
}
|
||||
else {
|
||||
$sql.=" ORDER BY ";
|
||||
}
|
||||
$sql.=$tabsqlsort[$id];
|
||||
$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'].'">';
|
||||
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused=0;
|
||||
$var=false;
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused=0;
|
||||
$var=false;
|
||||
|
||||
$fieldlist=explode(',',$tabfield[$id]);
|
||||
$fieldlist=explode(',',$tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// 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
|
||||
$align="left";
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
|
||||
{
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// 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
|
||||
$align="left";
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
|
||||
{
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
|
||||
|
||||
if ($valuetoshow != '')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
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>';
|
||||
else if (! 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 ($valuetoshow != '')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
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>';
|
||||
else if (! 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;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
print '</td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '</tr>';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
print '</td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Line to enter new values
|
||||
print '<tr class="oddeven nodrag nodrap nohover">';
|
||||
// Line to enter new values
|
||||
print '<tr class="oddeven nodrag nodrap nohover">';
|
||||
|
||||
$obj = new stdClass();
|
||||
// If data was already input, we define them in obj to populate input fields.
|
||||
if (GETPOST('actionadd'))
|
||||
{
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val) != '')
|
||||
$obj->$val=GETPOST($val);
|
||||
}
|
||||
}
|
||||
$obj = new stdClass();
|
||||
// If data was already input, we define them in obj to populate input fields.
|
||||
if (GETPOST('actionadd'))
|
||||
{
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (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;
|
||||
$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;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
fieldListJournal($fieldlist,$obj,$tabname[$id],'add');
|
||||
}
|
||||
if (empty($reshook))
|
||||
{
|
||||
fieldListJournal($fieldlist,$obj,$tabname[$id],'add');
|
||||
}
|
||||
|
||||
print '<td colspan="4" align="right">';
|
||||
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
print '<td colspan="4" align="right">';
|
||||
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
|
||||
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);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$var=true;
|
||||
// List of available record in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$var=true;
|
||||
|
||||
$param = '&id='.$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')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
|
||||
$param = '&id='.$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')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
|
||||
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
print '<tr class="none"><td align="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>';
|
||||
}
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
print '<tr class="none"><td align="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 of lines
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
$align="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
/*
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre_filter liste_titre_add">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($filterfound)
|
||||
{
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
$align="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
$valuetoshow=$tmp['valuetoshow'];
|
||||
$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"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
|
||||
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
|
||||
$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]=='nature') { $valuetoshow=$langs->trans("Nature"); }
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($filterfound)
|
||||
{
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
if ($num)
|
||||
{
|
||||
// Lines with values
|
||||
while ($i < $num)
|
||||
{
|
||||
$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)))
|
||||
{
|
||||
$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;
|
||||
|
||||
if ($num)
|
||||
{
|
||||
// Lines with values
|
||||
while ($i < $num)
|
||||
{
|
||||
$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)))
|
||||
{
|
||||
$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');
|
||||
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldListJournal($fieldlist,$obj,$tabname[$id],'edit');
|
||||
print '<td align="center" colspan="4">';
|
||||
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 '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||
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
|
||||
|
||||
print '<td align="center" colspan="4">';
|
||||
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 '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||
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
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
if (empty($reshook))
|
||||
{
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1;
|
||||
$align="left";
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
if ($valuetoshow=='all') {
|
||||
$valuetoshow=$langs->trans('All');
|
||||
}
|
||||
else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$langs->load("accountancy");
|
||||
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
|
||||
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]});
|
||||
}
|
||||
|
||||
$showfield=1;
|
||||
$align="left";
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
if ($valuetoshow=='all') {
|
||||
$valuetoshow=$langs->trans('All');
|
||||
}
|
||||
else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
|
||||
$langs->load("accountancy");
|
||||
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
|
||||
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]});
|
||||
}
|
||||
|
||||
$class='tddict';
|
||||
$class='tddict';
|
||||
// Show value for field
|
||||
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Can an entry be erased or disabled ?
|
||||
$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; $canbedisabled = 0; }
|
||||
else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; }
|
||||
else if ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; }
|
||||
}
|
||||
// Can an entry be erased or disabled ?
|
||||
$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; $canbedisabled = 0; }
|
||||
else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; }
|
||||
else if ($obj->code == 'EF0') { $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):'');
|
||||
if ($param) $url .= '&'.$param;
|
||||
$url.='&';
|
||||
$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.='&';
|
||||
|
||||
// Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
else
|
||||
{
|
||||
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
|
||||
else print $langs->trans("AlwaysActive");
|
||||
}
|
||||
print "</td>";
|
||||
// Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
else
|
||||
{
|
||||
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
|
||||
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
|
||||
else print $langs->trans("AlwaysActive");
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
// Modify link
|
||||
if ($canbemodified) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
|
||||
else print '<td> </td>';
|
||||
// Modify link
|
||||
if ($canbemodified) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
|
||||
else print '<td> </td>';
|
||||
|
||||
// Delete link
|
||||
if ($iserasable)
|
||||
{
|
||||
print '<td align="center">';
|
||||
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
|
||||
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
|
||||
print '</td>';
|
||||
}
|
||||
else print '<td> </td>';
|
||||
// Delete link
|
||||
if ($iserasable)
|
||||
{
|
||||
print '<td align="center">';
|
||||
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
|
||||
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
|
||||
print '</td>';
|
||||
}
|
||||
else print '<td> </td>';
|
||||
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
@@ -569,7 +569,7 @@ if ($action == 'create') {
|
||||
|
||||
print_liste_field_titre("AccountAccountingShort");
|
||||
print_liste_field_titre("SubledgerAccount");
|
||||
print_liste_field_titre("Labelcompte");
|
||||
print_liste_field_titre("LabelAccount");
|
||||
print_liste_field_titre("Label");
|
||||
print_liste_field_titre("Debit", "", "", "", "", 'align="right"');
|
||||
print_liste_field_titre("Credit", "", "", "", "", 'align="right"');
|
||||
|
||||
@@ -98,8 +98,8 @@ $form = new Form($db);
|
||||
|
||||
|
||||
if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
|
||||
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
|
||||
}
|
||||
|
||||
|
||||
@@ -134,67 +134,67 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
$param = '';
|
||||
$filter = array ();
|
||||
if (! empty($search_date_start)) {
|
||||
$filter['t.doc_date>='] = $search_date_start;
|
||||
$tmp=dol_getdate($search_date_start);
|
||||
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
|
||||
$filter['t.doc_date>='] = $search_date_start;
|
||||
$tmp=dol_getdate($search_date_start);
|
||||
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_date_end)) {
|
||||
$filter['t.doc_date<='] = $search_date_end;
|
||||
$tmp=dol_getdate($search_date_end);
|
||||
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
|
||||
$filter['t.doc_date<='] = $search_date_end;
|
||||
$tmp=dol_getdate($search_date_end);
|
||||
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_doc_date)) {
|
||||
$filter['t.doc_date'] = $search_doc_date;
|
||||
$tmp=dol_getdate($search_doc_date);
|
||||
$param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
|
||||
$filter['t.doc_date'] = $search_doc_date;
|
||||
$tmp=dol_getdate($search_doc_date);
|
||||
$param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type=' . $search_doc_type;
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type=' . $search_doc_type;
|
||||
}
|
||||
if (! empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . $search_doc_ref;
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . $search_doc_ref;
|
||||
}
|
||||
if (! empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
}
|
||||
if (! empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
}
|
||||
if (! empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code)) {
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_start)) {
|
||||
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
|
||||
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_end)) {
|
||||
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
}
|
||||
if (! empty($search_mvt_label)) {
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . $search_mvt_label;
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . $search_mvt_label;
|
||||
}
|
||||
if (! empty($search_direction)) {
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . $search_direction;
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . $search_direction;
|
||||
}
|
||||
if (! empty($search_ledger_code)) {
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . $search_ledger_code;
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . $search_ledger_code;
|
||||
}
|
||||
if (! empty($search_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . $search_mvt_num;
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . $search_mvt_num;
|
||||
}
|
||||
|
||||
if ($action == 'delbookkeeping') {
|
||||
@@ -229,16 +229,16 @@ if ($action == 'delbookkeepingyearconfirm') {
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||
}
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages("NoRecordDeleted", null, 'warnings');
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
setEventMessages("NoRecordDeleted", null, 'warnings');
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($action == 'delmouvconfirm') {
|
||||
@@ -248,11 +248,11 @@ if ($action == 'delmouvconfirm') {
|
||||
if (! empty($mvt_num)) {
|
||||
$result = $object->deleteMvtNum($mvt_num);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
}
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
@@ -262,21 +262,21 @@ if ($action == 'delmouvconfirm') {
|
||||
// Export into a file with format defined into setup
|
||||
if ($action == 'export_file') {
|
||||
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
);
|
||||
$form_question['deljournal'] = array (
|
||||
'name' => 'deljournal',
|
||||
'type' => 'other', // We don't use select here, the journal_array is already a select html component
|
||||
'type' => 'other', // We don't use select here, the journal_array is already a select html component
|
||||
'label' => $langs->trans('DelJournal'),
|
||||
'value' => $journal_array,
|
||||
'default' => $deljournal
|
||||
@@ -340,7 +340,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
//$param=''; param started before
|
||||
//$param=''; param started before
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
|
||||
@@ -399,28 +399,28 @@ print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
|
||||
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
|
||||
}
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
|
||||
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
@@ -489,8 +489,8 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
if ($num < $limit) print '<td align="left" colspan="6">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left" colspan="6">'.$langs->trans("Totalforthispage").'</td>';
|
||||
if ($num < $limit) print '<td align="left" colspan="7">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left" colspan="7">'.$langs->trans("Totalforthispage").'</td>';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print price($total_debit);
|
||||
|
||||
@@ -196,7 +196,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" );
|
||||
// print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" );
|
||||
// print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" );
|
||||
print_liste_field_titre("Labelcompte", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("Debit", "liste.php", "bk.debit" );
|
||||
print_liste_field_titre("Credit", "liste.php", "bk.credit" );
|
||||
// print_liste_field_titre("Amount", "liste.php", "bk.montant" );
|
||||
|
||||
@@ -205,7 +205,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" );
|
||||
// print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" );
|
||||
// print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" );
|
||||
print_liste_field_titre("Labelcompte", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("Debit", "liste.php", "bk.debit" );
|
||||
print_liste_field_titre("Credit", "liste.php", "bk.credit" );
|
||||
print_liste_field_titre("Amount", "liste.php", "bk.montant" );
|
||||
|
||||
@@ -419,7 +419,7 @@ class AccountancyExport
|
||||
|
||||
|
||||
/**
|
||||
* Export format : Agiris
|
||||
* Export format : Agiris Isacompta
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
@@ -433,30 +433,23 @@ class AccountancyExport
|
||||
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
|
||||
print $line->piece_num . $this->separator;
|
||||
print $line->label_operation . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
|
||||
print $line->label_operation . $this->separator;
|
||||
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte) . $this->separator;
|
||||
} else {
|
||||
// FIXME Because the subledger_account is already an accounting account, does we really need
|
||||
// to concat 4011 or 401 to it ?
|
||||
if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') {
|
||||
print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
|
||||
}
|
||||
if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') {
|
||||
print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
|
||||
}
|
||||
print length_accounta($line->subledger_account) . $this->separator;
|
||||
}
|
||||
|
||||
print length_accounta($line->subledger_account) . $this->separator;
|
||||
print $line->doc_ref . $this->separator;
|
||||
print price($line->debit) . $this->separator;
|
||||
print price($line->credit) . $this->separator;
|
||||
print price($line->montant).$this->separator;
|
||||
print $line->sens.$this->separator;
|
||||
print $line->code_journal . $this->separator;
|
||||
print $line->code_journal;
|
||||
print $this->end_line;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -310,6 +310,7 @@ if ($resql) {
|
||||
}
|
||||
else print length_accountg($row[0]);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
if ($row[0] == 'tobind')
|
||||
{
|
||||
@@ -317,7 +318,7 @@ if ($resql) {
|
||||
}
|
||||
else print $row[1];
|
||||
print '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -422,7 +422,6 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $val["label"];
|
||||
$bookkeeping->label_compte = $langs->trans("Bank");
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
@@ -433,21 +432,28 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
// No subledger_account value for the bank line
|
||||
// No subledger_account value for the bank line but add a specific label_operation
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'unknown') {
|
||||
// ???
|
||||
$bookkeeping->subledger_account = '';
|
||||
@@ -484,7 +490,6 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
@@ -495,55 +500,55 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $objmid->labelc;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
@@ -676,9 +681,9 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
@@ -720,9 +725,9 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
@@ -823,7 +828,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -298,7 +298,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
|
||||
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %';
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
@@ -552,7 +552,7 @@ if (empty($action) || $action == 'view') {
|
||||
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("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@@ -659,7 +659,7 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
|
||||
@@ -100,9 +100,9 @@ $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ?
|
||||
$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.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) . "'";
|
||||
@@ -151,7 +151,7 @@ if ($result) {
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
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.')':''));
|
||||
}
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
@@ -224,7 +224,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
@@ -272,12 +272,12 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $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->thirdparty_code = $companystatic->code_fournisseur;
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
@@ -326,7 +326,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
@@ -335,7 +335,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
@@ -374,8 +374,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +419,6 @@ $form = new Form($db);
|
||||
// Export
|
||||
if ($action == 'exportcsv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
@@ -445,7 +444,7 @@ if ($action == 'exportcsv') {
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $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;
|
||||
@@ -465,11 +464,11 @@ if ($action == 'exportcsv') {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $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 '""' . $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;
|
||||
@@ -478,6 +477,7 @@ if ($action == 'exportcsv') {
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
$listoftax = array(0, 1, 2);
|
||||
foreach ($listoftax as $numtax) {
|
||||
@@ -489,13 +489,13 @@ if ($action == 'exportcsv') {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $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 '""' . $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 '"' . 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 . '"' ;
|
||||
@@ -531,15 +531,15 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
// Button to write into Ledger
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
}
|
||||
else {
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
}
|
||||
print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
print '</div>';
|
||||
@@ -565,7 +565,7 @@ if (empty($action) || $action == 'view') {
|
||||
print '<br>';
|
||||
|
||||
$i = 0;
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td></td>";
|
||||
@@ -573,7 +573,7 @@ if (empty($action) || $action == 'view') {
|
||||
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("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@@ -625,8 +625,9 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
@@ -683,7 +684,7 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
|
||||
@@ -156,7 +156,7 @@ if ($result) {
|
||||
$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.')':''));
|
||||
}
|
||||
@@ -295,7 +295,7 @@ if ($action == 'writebookkeeping') {
|
||||
$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->thirdparty_code = $companystatic->code_client;
|
||||
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
@@ -353,7 +353,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
|
||||
@@ -392,8 +392,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,6 @@ $form = new Form($db);
|
||||
if ($action == 'exportcsv') {
|
||||
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
@@ -472,7 +471,7 @@ if ($action == 'exportcsv') {
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
|
||||
@@ -487,12 +486,12 @@ if ($action == 'exportcsv') {
|
||||
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 '""' . $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 '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@@ -512,12 +511,12 @@ if ($action == 'exportcsv') {
|
||||
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 '""' . $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 '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@@ -551,12 +550,12 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
// Button to write into Ledger
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
}
|
||||
else {
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
@@ -593,7 +592,7 @@ if (empty($action) || $action == 'view') {
|
||||
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("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@@ -699,7 +698,7 @@ 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 align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
|
||||
@@ -38,6 +38,28 @@ $langs->load("members");
|
||||
|
||||
$id = GETPOST('id','int')?GETPOST('id','int'):GETPOST('rowid','int');
|
||||
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$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 = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield='a.datep,a.id';
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
|
||||
if (GETPOST('actioncode','array'))
|
||||
{
|
||||
$actioncode=GETPOST('actioncode','array',3);
|
||||
if (! count($actioncode)) $actioncode='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label=GETPOST('search_agenda_label');
|
||||
|
||||
// Security check
|
||||
$result=restrictedArea($user,'adherent',$id);
|
||||
|
||||
@@ -56,7 +78,26 @@ if ($result > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// None
|
||||
$parameters=array('id'=>$id, 'objcanvas'=>$objcanvas);
|
||||
$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))
|
||||
{
|
||||
// Cancel
|
||||
if (GETPOST('cancel','alpha') && ! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
$actioncode='';
|
||||
$search_agenda_label='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,41 +128,49 @@ if ($object->id > 0)
|
||||
|
||||
dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
$object->info($id);
|
||||
print dol_print_object_info($object, 1);
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'action
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
|
||||
|
||||
$morehtmlcenter = '';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a></div>';
|
||||
$morehtmlcenter.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
$out='';
|
||||
$param='&id='.$id;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnMember"),$out,'');
|
||||
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
// List of actions
|
||||
show_actions_done($conf,$langs,$db,$object,null,0,'','');
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
$filters['search_agenda_label']=$search_agenda_label;
|
||||
|
||||
// TODO Replace this with same code than into listactions.php
|
||||
show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1431,7 +1431,7 @@ else
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
|
||||
if (! empty($conf->societe->enabled)) $rowspan++;
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
@@ -1799,10 +1799,16 @@ else
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
$MAX = 10;
|
||||
|
||||
$morehtmlright = '<a href="'.DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id.'">';
|
||||
$morehtmlright.= $langs->trans("SeeAll");
|
||||
$morehtmlright.= '</a>';
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', 10);
|
||||
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,11 +55,11 @@ class AdherentType extends CommonObject
|
||||
* @since 5.0
|
||||
*/
|
||||
public $subscription;
|
||||
/** @var string Public note */
|
||||
/** @var string Public note */
|
||||
public $note;
|
||||
/** @var bool Can vote*/
|
||||
/** @var integer Can vote */
|
||||
public $vote;
|
||||
/** @var bool Email sent during validation */
|
||||
/** @var string Email sent during validation */
|
||||
public $mail_valid;
|
||||
/** @var array Array of members */
|
||||
public $members=array();
|
||||
@@ -481,7 +481,7 @@ class AdherentType extends CommonObject
|
||||
|
||||
// Initialise parametres
|
||||
$this->id = 0;
|
||||
$this->ref = 0;
|
||||
$this->ref = 'MTSPEC';
|
||||
$this->specimen=1;
|
||||
|
||||
$this->label='MEMBERS TYPE SPECIMEN';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,6 +20,7 @@ use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
/**
|
||||
* API class for members
|
||||
@@ -357,4 +359,38 @@ class Members extends DolibarrApi
|
||||
return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get categories for a member
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ if ($id > 0)
|
||||
$result=$membert->fetch($object->typeid);
|
||||
if ($result > 0)
|
||||
{
|
||||
|
||||
|
||||
// Construit liste des fichiers
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
$totalsize=0;
|
||||
@@ -102,7 +102,7 @@ if ($id > 0)
|
||||
{
|
||||
$totalsize+=$file['size'];
|
||||
}
|
||||
|
||||
|
||||
if (! empty($conf->notification->enabled))
|
||||
$langs->load("mails");
|
||||
|
||||
@@ -110,12 +110,12 @@ if ($id > 0)
|
||||
|
||||
dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
@@ -153,7 +153,7 @@ if ($id > 0)
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'member';
|
||||
|
||||
@@ -59,26 +59,23 @@ if (! $result)
|
||||
|
||||
if ($action == 'dolibarr2ldap')
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$ldap=new Ldap();
|
||||
$result=$ldap->connect_bind();
|
||||
|
||||
$info=$object->_load_ldap_info();
|
||||
$dn=$object->_load_ldap_dn($info);
|
||||
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
||||
|
||||
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||
|
||||
if ($result >= 0)
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs');
|
||||
$db->commit();
|
||||
$info=$object->_load_ldap_info();
|
||||
$dn=$object->_load_ldap_dn($info);
|
||||
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
||||
|
||||
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ($result >= 0) {
|
||||
setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs');
|
||||
}
|
||||
else {
|
||||
setEventMessages($ldap->errors, $ldap->error, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +93,7 @@ $head = member_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ if ($id)
|
||||
print "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
|
||||
$paiement = new Paiement($db);
|
||||
$paiement->datepaye = $paymentdate;
|
||||
$paiement->amounts = $amounts;
|
||||
$paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement');
|
||||
$paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',1);
|
||||
$paiement->num_paiement = $num_chq;
|
||||
$paiement->note = $label;
|
||||
|
||||
@@ -601,7 +601,7 @@ if ($rowid > 0)
|
||||
|
||||
dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ if ($rowid > 0)
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ $head = member_type_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ if ($action == "save" && empty($cancel))
|
||||
{
|
||||
$param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
|
||||
//print "param=".$param." - ".$_POST[$param];
|
||||
if (GETPOST($param,'alpha')) $res = dolibarr_set_const($db,$param,GETPOST($param,'alpha'),'chaine',0,'',$conf->entity);
|
||||
else $res = dolibarr_del_const($db,$param,$conf->entity);
|
||||
$res = dolibarr_set_const($db,$param,(GETPOST($param,'alpha')?GETPOST($param,'alpha'):''),'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -45,10 +45,18 @@ if (! $user->admin) accessforbidden();
|
||||
|
||||
$error=0;
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$contextpage=array('admincompany','globaladmin');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$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') )
|
||||
{
|
||||
|
||||
@@ -269,12 +269,12 @@ if ($mode != 'focus')
|
||||
{
|
||||
if ($mode != 'sortorder')
|
||||
{
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST
|
||||
unset($substitutionarray['__USER_SIGNATURE__']);
|
||||
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach($substitutionarray as $key => $val)
|
||||
{
|
||||
$texthelp.=$key.'<br>';
|
||||
$texthelp.=$key.' -> '.$val.'<br>';
|
||||
}
|
||||
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
|
||||
}
|
||||
|
||||
@@ -137,7 +137,17 @@ if ($action == 'update')
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
|
||||
|
||||
// For update value with percentage
|
||||
$plus='';
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
|
||||
// Update values
|
||||
for($i=0;$i<4;$i++) {
|
||||
if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -196,13 +206,6 @@ if ($action == 'edit')
|
||||
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
|
||||
print '<br>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -244,21 +247,30 @@ else
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Boutons d'action
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Show logo for weather
|
||||
print $langs->trans("DescWeather").'<br>';
|
||||
|
||||
if($action == 'edit') {
|
||||
|
||||
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
|
||||
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
|
||||
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
|
||||
else $str_mode_enabled = $str_mode_percentage;
|
||||
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
|
||||
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
} else {
|
||||
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
|
||||
else print $langs->trans('MeteoPercentageModEnabled');
|
||||
print '<br><br>';
|
||||
}
|
||||
|
||||
$offset=0;
|
||||
$cursor=10; // By default
|
||||
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
|
||||
@@ -267,36 +279,143 @@ $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level
|
||||
$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
|
||||
$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
|
||||
$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
|
||||
$text=''; $options='height="60px"';
|
||||
print '<table>';
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '</td><td>= '.$level0.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '</td><td><= '.$level1.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '</td><td><= '.$level2.'</td>';
|
||||
print '</tr>';
|
||||
$text=''; $options='class="valignmiddle" height="60px"';
|
||||
|
||||
print '<tr><td>';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '</td><td><= '.$level3.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '</td><td>> '.$level3.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
if ($action == 'edit') {
|
||||
|
||||
|
||||
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png', $options);
|
||||
print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/> %</td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#change_mode").click(function() {
|
||||
var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
|
||||
var str_mode_std = "<?php print $str_mode_std; ?>";
|
||||
var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
|
||||
|
||||
if(use_percent.val() == 1) {
|
||||
use_percent.val(0);
|
||||
$("#standard").show();
|
||||
$("#percentage").hide();
|
||||
$(this).html(str_mode_std);
|
||||
} else {
|
||||
use_percent.val(1);
|
||||
$("#standard").hide();
|
||||
$("#percentage").show();
|
||||
$(this).html(str_mode_percentage);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= '.$level0;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= '.$level1;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= '.$level2;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= '.$level3;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '> '.$level3;
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if($action == 'edit') {
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
|
||||
print '<br></form>';
|
||||
|
||||
} else {
|
||||
|
||||
// Boutons d'action
|
||||
print '<br><div class="tabsAction">';
|
||||
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
|
||||
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
|
||||
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
|
||||
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -54,6 +54,7 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$id=GETPOST('id','int');
|
||||
$rowid=GETPOST('rowid','alpha');
|
||||
$entity=GETPOST('entity','int');
|
||||
$code=GETPOST('code','alpha');
|
||||
|
||||
$allowed=$user->admin;
|
||||
@@ -181,8 +182,8 @@ $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as
|
||||
$tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
|
||||
$tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||
$tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
|
||||
$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
|
||||
$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c";
|
||||
$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]);
|
||||
$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]);
|
||||
$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
|
||||
$tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
@@ -259,8 +260,8 @@ $tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE
|
||||
$tabfield[9] = "code,label,unicode";
|
||||
$tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[11]= "element,source,code,libelle,position";
|
||||
$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
|
||||
$tabfield[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
|
||||
$tabfield[13]= "code,libelle,type,accountancy_code,entity";
|
||||
$tabfield[14]= "code,libelle,price,organization,country_id,country";
|
||||
$tabfield[15]= "code,libelle,width,height,unit";
|
||||
$tabfield[16]= "code,libelle,sortorder";
|
||||
@@ -335,8 +336,8 @@ $tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_S
|
||||
$tabfieldinsert[9] = "code_iso,label,unicode";
|
||||
$tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[11]= "element,source,code,libelle,position";
|
||||
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
|
||||
$tabfieldinsert[13]= "code,libelle,type,accountancy_code";
|
||||
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
|
||||
$tabfieldinsert[13]= "code,libelle,type,accountancy_code,entity";
|
||||
$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
|
||||
$tabfieldinsert[15]= "code,label,width,height,unit";
|
||||
$tabfieldinsert[16]= "code,label,sortorder";
|
||||
@@ -733,7 +734,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
|
||||
}
|
||||
else if ($value == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
$_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]);
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
|
||||
@@ -785,7 +786,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
|
||||
}
|
||||
else if ($field == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
$_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]);
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
$sql.= $field."=";
|
||||
@@ -798,6 +799,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
$i++;
|
||||
}
|
||||
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
|
||||
$sql.= " AND entity = '".getEntity($tabname[$id])."'";
|
||||
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
@@ -820,7 +822,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
@@ -844,10 +846,10 @@ if ($action == $acts[0])
|
||||
else { $rowidcol="rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -864,10 +866,10 @@ if ($action == $acts[1])
|
||||
else { $rowidcol="rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -884,10 +886,10 @@ if ($action == 'activate_favorite')
|
||||
else { $rowidcol="rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -904,10 +906,10 @@ if ($action == 'disable_favorite')
|
||||
else { $rowidcol="rowid"; }
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'";
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : '');
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -959,6 +961,7 @@ print "<br>\n";
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
|
||||
if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id);
|
||||
if ($entity != '') $param.= '&entity=' . (int) $entity;
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
|
||||
@@ -1016,6 +1019,7 @@ if ($id)
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused=0;
|
||||
$withentity=null;
|
||||
|
||||
$fieldlist=explode(',',$tabfield[$id]);
|
||||
|
||||
@@ -1026,6 +1030,11 @@ if ($id)
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'entity') {
|
||||
$withentity = getEntity($tabname[$id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
|
||||
@@ -1119,6 +1128,8 @@ if ($id)
|
||||
if ($id == 4) print '<td></td>';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
if (! is_null($withentity))
|
||||
print '<input type="hidden" name="entity" value="'.$withentity.'">';
|
||||
print '</td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
@@ -1197,7 +1208,9 @@ if ($id)
|
||||
$filterfound=0;
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1; // By defaut
|
||||
if ($fieldlist[$field] == 'entity') continue;
|
||||
|
||||
$showfield=1; // By default
|
||||
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
|
||||
@@ -1239,6 +1252,8 @@ if ($id)
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'entity') continue;
|
||||
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
@@ -1349,12 +1364,16 @@ if ($id)
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
if (empty($reshook)) {
|
||||
$withentity = fieldList($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
}
|
||||
|
||||
print '<td colspan="3" align="center">';
|
||||
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
if (! is_null($withentity))
|
||||
print '<input type="hidden" name="entity" value="'.$withentity.'">';
|
||||
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 '</td>';
|
||||
@@ -1369,11 +1388,19 @@ if ($id)
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$withentity=null;
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1;
|
||||
$showfield=1;
|
||||
$align="left";
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
$valuetoshow=$obj->{$fieldlist[$field]};
|
||||
|
||||
if ($fieldlist[$field] == 'entity') {
|
||||
$withentity = $valuetoshow;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value == 'element')
|
||||
{
|
||||
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
|
||||
@@ -1588,7 +1615,8 @@ if ($id)
|
||||
// If rowidcol not defined
|
||||
if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27))) $rowidcol='rowid';
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((! empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0')?$obj->{$rowidcol}:(! empty($obj->code)?urlencode($obj->code):'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
|
||||
if ($param) $url .= '&'.$param;
|
||||
if (! empty($param)) $url .= '&'.$param;
|
||||
if (! is_null($withentity)) $url .= '&entity='.$withentity;
|
||||
$url.='&';
|
||||
|
||||
// Favorite
|
||||
@@ -1721,7 +1749,7 @@ $db->close();
|
||||
* @param Object $obj If we show a particular record, obj is filled with record fields
|
||||
* @param string $tabname Name of SQL table
|
||||
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
|
||||
* @return void
|
||||
* @return string '' or value of entity into table
|
||||
*/
|
||||
function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
{
|
||||
@@ -1735,8 +1763,15 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
$formcompany = new FormCompany($db);
|
||||
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
|
||||
$withentity='';
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'entity') {
|
||||
$withentity = $obj->{$fieldlist[$field]};
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system','systemauto')))
|
||||
{
|
||||
$hidden = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'');
|
||||
@@ -1948,5 +1983,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
return $withentity;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,19 +57,19 @@ if (! defined("MAIN_MOTD")) define("MAIN_MOTD","");
|
||||
|
||||
if (GETPOST('cancel','alpha'))
|
||||
{
|
||||
$action='';
|
||||
$action='';
|
||||
}
|
||||
|
||||
if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
|
||||
dol_delete_file($logofile);
|
||||
dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND",$conf->entity);
|
||||
$mysoc->logo='';
|
||||
$logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
|
||||
dol_delete_file($logofile);
|
||||
dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND",$conf->entity);
|
||||
$mysoc->logo='';
|
||||
|
||||
/*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
|
||||
/*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
|
||||
dol_delete_file($logosmallfile);
|
||||
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity);
|
||||
$mysoc->logo_small='';
|
||||
@@ -89,54 +89,58 @@ if ($action == 'update')
|
||||
|
||||
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
|
||||
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'),array()))));
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val,'chaine',0,'',$conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'),array()))));
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val,'chaine',0,'',$conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
|
||||
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
|
||||
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
|
||||
|
||||
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array()))));
|
||||
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
|
||||
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
|
||||
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
|
||||
@@ -147,43 +151,43 @@ if ($action == 'update')
|
||||
$varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
|
||||
if ($_FILES[$varforimage]["tmp_name"])
|
||||
{
|
||||
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
|
||||
{
|
||||
$original_file=$reg[1];
|
||||
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
|
||||
{
|
||||
$original_file=$reg[1];
|
||||
|
||||
$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))
|
||||
{
|
||||
dol_mkdir($dirforimage);
|
||||
}
|
||||
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"],$dirforimage.$original_file,1,0,$_FILES[$varforimage]['error']);
|
||||
if ($result > 0)
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND",$original_file,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$tmparray=explode(':',$result);
|
||||
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
|
||||
}
|
||||
}
|
||||
$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))
|
||||
{
|
||||
dol_mkdir($dirforimage);
|
||||
}
|
||||
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"],$dirforimage.$original_file,1,0,$_FILES[$varforimage]['error']);
|
||||
if ($result > 0)
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND",$original_file,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$tmparray=explode(':',$result);
|
||||
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,59 +218,59 @@ print "<br>\n";
|
||||
|
||||
if ($action == 'edit') // Edit
|
||||
{
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
clearstatcache();
|
||||
clearstatcache();
|
||||
|
||||
print '<br>';
|
||||
print '<table summary="edit" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td>';
|
||||
print '<br>';
|
||||
print '<table summary="edit" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Default language
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
|
||||
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
|
||||
print '</td>';
|
||||
// Default language
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
|
||||
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multilingual GUI
|
||||
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
|
||||
print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
|
||||
print '</td>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
|
||||
print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table><br>'."\n";
|
||||
|
||||
// Themes and themes options
|
||||
show_theme(null,1);
|
||||
print '<br>';
|
||||
// Themes and themes options
|
||||
show_theme(null,1);
|
||||
print '<br>';
|
||||
|
||||
// Other
|
||||
print '<table summary="edit" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
|
||||
// Other
|
||||
print '<table summary="edit" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Max size of lists
|
||||
print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
|
||||
print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Max size of short lists on customer card
|
||||
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
|
||||
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// show input border
|
||||
/*
|
||||
// show input border
|
||||
/*
|
||||
print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
|
||||
print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1);
|
||||
print '</td>';
|
||||
@@ -275,38 +279,38 @@ if ($action == 'edit') // Edit
|
||||
*/
|
||||
|
||||
// Disable javascript and ajax
|
||||
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
|
||||
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
|
||||
print '</td>';
|
||||
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
|
||||
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// First day for weeks
|
||||
print '<tr><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
|
||||
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
|
||||
print '</td>';
|
||||
// First day for weeks
|
||||
print '<tr><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
|
||||
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// DefaultWorkingDays
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
|
||||
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
|
||||
print '</td>';
|
||||
// DefaultWorkingDays
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
|
||||
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// DefaultWorkingHours
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
|
||||
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
|
||||
print '</td>';
|
||||
// DefaultWorkingHours
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
|
||||
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Firstname/Name
|
||||
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
|
||||
$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
|
||||
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
|
||||
print '</td>';
|
||||
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -342,27 +346,27 @@ if ($action == 'edit') // Edit
|
||||
print '</tr>';
|
||||
|
||||
// Hide wiki link on login page
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
|
||||
print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
|
||||
print '</td>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
|
||||
print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Message of the day on home page
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
|
||||
print '<tr><td class="titlefield">';
|
||||
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach($substitutionarray as $key => $val)
|
||||
{
|
||||
$texthelp.=$key.'<br>';
|
||||
}
|
||||
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
|
||||
print '<tr><td class="titlefield">';
|
||||
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach($substitutionarray as $key => $val)
|
||||
{
|
||||
$texthelp.=$key.'<br>';
|
||||
}
|
||||
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
|
||||
|
||||
print '</td><td colspan="2">';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
|
||||
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td></tr>'."\n";
|
||||
@@ -379,12 +383,12 @@ if ($action == 'edit') // Edit
|
||||
|
||||
// Message on login page
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user'));
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
print '<tr><td>';
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
print '<tr><td>';
|
||||
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach($substitutionarray as $key => $val)
|
||||
{
|
||||
$texthelp.=$key.'<br>';
|
||||
$texthelp.=$key.'<br>';
|
||||
}
|
||||
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin');
|
||||
print '</td><td colspan="2">';
|
||||
@@ -401,16 +405,16 @@ if ($action == 'edit') // Edit
|
||||
|
||||
// Background
|
||||
print '<tr><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">';
|
||||
print '<div class="centpercent inline-block">';
|
||||
print '<div class="centpercent inline-block">';
|
||||
print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground">';
|
||||
if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=removebackgroundlogin">'.img_delete($langs->trans("Delete")).'</a>';
|
||||
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
|
||||
print ' ';
|
||||
print '<img class="paddingleft valignmiddle" width="100px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('/'.$conf->global->MAIN_LOGIN_BACKGROUND).'">';
|
||||
}
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=removebackgroundlogin">'.img_delete($langs->trans("Delete")).'</a>';
|
||||
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
|
||||
print ' ';
|
||||
print '<img class="paddingleft valignmiddle" width="100px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('/'.$conf->global->MAIN_LOGIN_BACKGROUND).'">';
|
||||
}
|
||||
} else {
|
||||
print '<img class="paddingleft valignmiddle" width="100" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
||||
print '<img class="paddingleft valignmiddle" width="100" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
@@ -418,31 +422,31 @@ if ($action == 'edit') // Edit
|
||||
print '</table>'."\n";
|
||||
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
}
|
||||
else // Show
|
||||
{
|
||||
// Language
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td><td> </td></tr>';
|
||||
// Language
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td><td> </td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
|
||||
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
|
||||
print ($s?$s.' ':'');
|
||||
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
|
||||
print '</td>';
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
|
||||
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
|
||||
print ($s?$s.' ':'');
|
||||
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
|
||||
print '</td>';
|
||||
print '<td width="20">';
|
||||
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
|
||||
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
@@ -450,19 +454,19 @@ else // Show
|
||||
|
||||
|
||||
// Themes
|
||||
show_theme(null,0);
|
||||
print '<br>';
|
||||
show_theme(null,0);
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Other
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
|
||||
// Other
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
@@ -473,38 +477,38 @@ else // Show
|
||||
print "</tr>";
|
||||
*/
|
||||
|
||||
// Disable javascript/ajax
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableJavascript").'</td><td>';
|
||||
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
// Disable javascript/ajax
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableJavascript").'</td><td>';
|
||||
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
// First day for weeks
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
|
||||
print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
|
||||
print '</td>';
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
|
||||
print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// DefaultWorkingDays
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
|
||||
print isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5';
|
||||
print '</td>';
|
||||
// DefaultWorkingDays
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
|
||||
print isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5';
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// DefaultWorkingHours
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
|
||||
print isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18';
|
||||
print '</td>';
|
||||
// DefaultWorkingHours
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
|
||||
print isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18';
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Firstname / Name position
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
|
||||
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
|
||||
else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
|
||||
print '</td>';
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
|
||||
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
|
||||
else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -513,8 +517,8 @@ else // Show
|
||||
print yn((isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Show logo
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
|
||||
// Show logo
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
@@ -527,62 +531,62 @@ else // Show
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
// Show bugtrack link
|
||||
// Show bugtrack link
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
|
||||
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
|
||||
print '<td width="20"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
// Link to wiki help
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
|
||||
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
|
||||
print '</td></tr>';
|
||||
// Link to wiki help
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
|
||||
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Message of the day
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
|
||||
if (isset($conf->global->MAIN_MOTD)) print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
|
||||
else print ' ';
|
||||
print '</td></tr>'."\n";
|
||||
// Message of the day
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
|
||||
if (isset($conf->global->MAIN_MOTD)) print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
|
||||
else print ' ';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</table>'."\n";
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
// Login page
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("LoginPage").'</td><td></td><td> </td></tr>';
|
||||
// Login page
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("LoginPage").'</td><td></td><td> </td></tr>';
|
||||
|
||||
// Message login
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
|
||||
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
|
||||
else print ' ';
|
||||
print '</td></tr>'."\n";
|
||||
// Message login
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
|
||||
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
|
||||
else print ' ';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Link to help center
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
|
||||
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
|
||||
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Background login
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("BackgroundImageLogin").'</td><td colspan="2">';
|
||||
print '<div class="centpercent inline-block">';
|
||||
print $conf->global->MAIN_LOGIN_BACKGROUND;
|
||||
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
|
||||
{
|
||||
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
// Background login
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("BackgroundImageLogin").'</td><td colspan="2">';
|
||||
print '<div class="centpercent inline-block">';
|
||||
print $conf->global->MAIN_LOGIN_BACKGROUND;
|
||||
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
|
||||
{
|
||||
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</table>'."\n";
|
||||
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -66,8 +66,9 @@ if ($action == 'setvalue' && $user->admin)
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO',GETPOST("fieldphoneperso"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++;
|
||||
@@ -84,22 +85,22 @@ if ($action == 'setvalue' && $user->admin)
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
|
||||
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
$key=GETPOST("key");
|
||||
if ($key) $valkey=$conf->global->$key;
|
||||
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
$key=GETPOST("key");
|
||||
if ($key) $valkey=$conf->global->$key;
|
||||
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -282,6 +283,14 @@ print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Address
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
|
||||
|
||||
@@ -63,28 +63,33 @@ if ($action == 'setvalue' && $user->admin)
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',GETPOST("fieldcountry"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE',GETPOST("fieldtitle"),'chaine',0,'',$conf->entity)) $error++;
|
||||
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
$key=GETPOST("key");
|
||||
if ($key) $valkey=$conf->global->$key;
|
||||
if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
$key=GETPOST("key");
|
||||
if ($key) $valkey=$conf->global->$key;
|
||||
if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +213,7 @@ print '</tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_FIELD_PASSWORD.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD)?' checked':'')."></td>";
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Password crypted
|
||||
@@ -216,7 +221,7 @@ print '</tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_FIELD_PASSWORD_CRYPTED.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD_CRYPTED"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD_CRYPTED)?' checked':'')."></td>";
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Mail
|
||||
@@ -259,12 +264,52 @@ print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
|
||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked':'')."></td>";
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_FIELD_COMPANY.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Address
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_FIELD_ADDRESS.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// ZIP
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_FIELD_ZIP.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// TOWN
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_FIELD_TOWN.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// COUNTRY
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_FIELD_COUNTRY.'">';
|
||||
print '</td><td> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Title
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTitle").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldtitle" value="'.$conf->global->LDAP_FIELD_TITLE.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldTitleExample").'</td>';
|
||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_TITLE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_TITLE)?' checked':'')."></td>";
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Note
|
||||
@@ -272,7 +317,7 @@ print '</tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Note").'</td><td>';
|
||||
print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
|
||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_DESCRIPTION)?' checked':'')."></td>";
|
||||
print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Sid
|
||||
@@ -385,7 +430,7 @@ if (function_exists("ldap_connect"))
|
||||
{
|
||||
$required_fields = array(
|
||||
$conf->global->LDAP_KEY_USERS,
|
||||
$conf->global->LDAP_FIELD_FULLNAME,
|
||||
$conf->global->LDAP_FIELD_FULLNAME,
|
||||
$conf->global->LDAP_FIELD_NAME,
|
||||
$conf->global->LDAP_FIELD_FIRSTNAME,
|
||||
$conf->global->LDAP_FIELD_LOGIN,
|
||||
@@ -394,7 +439,7 @@ if (function_exists("ldap_connect"))
|
||||
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
|
||||
$conf->global->LDAP_FIELD_PHONE,
|
||||
$conf->global->LDAP_FIELD_FAX,
|
||||
$conf->global->LDAP_FIELD_SKYPE,
|
||||
$conf->global->LDAP_FIELD_SKYPE,
|
||||
$conf->global->LDAP_FIELD_MOBILE,
|
||||
$conf->global->LDAP_FIELD_MAIL,
|
||||
$conf->global->LDAP_FIELD_TITLE,
|
||||
@@ -402,35 +447,35 @@ if (function_exists("ldap_connect"))
|
||||
$conf->global->LDAP_FIELD_SID
|
||||
);
|
||||
|
||||
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
|
||||
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
|
||||
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
|
||||
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
|
||||
|
||||
// Get from LDAP database an array of results
|
||||
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
|
||||
//$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1);
|
||||
// Get from LDAP database an array of results
|
||||
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
|
||||
//$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1);
|
||||
|
||||
if (is_array($ldapusers))
|
||||
{
|
||||
$liste=array();
|
||||
foreach ($ldapusers as $key => $ldapuser)
|
||||
{
|
||||
// Define the label string for this user
|
||||
$label='';
|
||||
foreach ($required_fields as $value)
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$label.=$value."=".$ldapuser[$value]." ";
|
||||
}
|
||||
}
|
||||
$liste[$key] = $label;
|
||||
}
|
||||
if (is_array($ldapusers))
|
||||
{
|
||||
$liste=array();
|
||||
foreach ($ldapusers as $key => $ldapuser)
|
||||
{
|
||||
// Define the label string for this user
|
||||
$label='';
|
||||
foreach ($required_fields as $value)
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$label.=$value."=".$ldapuser[$value]." ";
|
||||
}
|
||||
}
|
||||
$liste[$key] = $label;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||
}
|
||||
|
||||
print "<br>\n";
|
||||
print "LDAP search for user:<br>\n";
|
||||
|
||||
@@ -53,7 +53,6 @@ $id=GETPOST('id','int');
|
||||
$rowid=GETPOST('rowid','alpha');
|
||||
$search_label=GETPOST('search_label','alpha');
|
||||
$search_type_template=GETPOST('search_type_template','alpha');
|
||||
$search_topic=GETPOST('search_topic','alpha');
|
||||
$search_lang=GETPOST('search_lang','alpha');
|
||||
$search_fk_user=GETPOST('search_fk_user','intcomma');
|
||||
$search_topic=GETPOST('search_topic','alpha');
|
||||
@@ -94,26 +93,20 @@ $tabsqlsort[25]="label ASC, lang ASC, position ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[25]= "label,type_template,lang,fk_user,private,position,topic,content";
|
||||
$tabfield[25]= "label,type_template,lang,fk_user,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines';
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[25]= "label,type_template,fk_user,lang,private,position,topic,content";
|
||||
$tabfieldvalue[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines';
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[25]= "label,type_template,fk_user,lang,private,position,topic,content";
|
||||
$tabfieldinsert[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines';
|
||||
$tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays
|
||||
|
||||
// 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[25]= "";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond=array();
|
||||
$tabcond[25]= true;
|
||||
@@ -153,7 +146,7 @@ else
|
||||
|
||||
|
||||
$tabhelp=array();
|
||||
$tabhelp[25] = array('topic'=>$helpsubstit,'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
|
||||
$tabhelp[25] = array('topic'=>$helpsubstit,'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
|
||||
|
||||
// List of check for fields (NOT USED YET)
|
||||
$tabfieldcheck=array();
|
||||
@@ -177,6 +170,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la
|
||||
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
|
||||
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
|
||||
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
|
||||
$elementList['user']=$langs->trans('MailToUser');
|
||||
$elementList['all'] =$langs->trans('VisibleEverywhere');
|
||||
$elementList['none']=$langs->trans('VisibleNowhere');
|
||||
|
||||
@@ -229,10 +223,12 @@ if (empty($reshook))
|
||||
$ok=1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
// Not mandatory fields
|
||||
if ($value == 'joinfiles') continue;
|
||||
if ($value == 'content') continue;
|
||||
if ($value == 'content_lines') continue;
|
||||
if ($value == 'content') $value='content-'.$rowid;
|
||||
if ($value == 'content_lines') $value='content_lines-'.$rowid;
|
||||
|
||||
if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
|
||||
|
||||
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
|
||||
{
|
||||
@@ -256,34 +252,14 @@ if (empty($reshook))
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd'))
|
||||
{
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
// Recupere id libre pour insertion
|
||||
$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);
|
||||
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// 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(";
|
||||
|
||||
// List of values
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
|
||||
$sql.= $newid.",";
|
||||
$i=0;
|
||||
foreach ($listfieldinsert as $f => $value)
|
||||
{
|
||||
@@ -322,17 +298,11 @@ if (empty($reshook))
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
$rowidcol="rowid";
|
||||
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
|
||||
{
|
||||
$sql.= $tabrowid[$id]."=";
|
||||
$sql.= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
{
|
||||
@@ -340,8 +310,10 @@ if (empty($reshook))
|
||||
if ($field == 'lang') $keycode='langcode';
|
||||
|
||||
if ($field == 'fk_user' && ! ($_POST['fk_user'] > 0)) $_POST['fk_user']='';
|
||||
if ($field == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
|
||||
if ($field == 'joinfiles') $_POST['joinfiles']=$_POST['joinfiles-'.$rowid];
|
||||
if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
|
||||
if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
|
||||
if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
|
||||
if ($field == 'entity') $_POST[$keycode] = $conf->entity;
|
||||
if ($i) $sql.=",";
|
||||
$sql.= $field."=";
|
||||
@@ -354,7 +326,11 @@ if (empty($reshook))
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
if ($resql)
|
||||
{
|
||||
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
@@ -363,8 +339,7 @@ if (empty($reshook))
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
$rowidcol="rowid";
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
|
||||
|
||||
@@ -386,15 +361,9 @@ if (empty($reshook))
|
||||
// activate
|
||||
if ($action == $acts[0])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
$rowidcol="rowid";
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
|
||||
}
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
@@ -406,15 +375,9 @@ if (empty($reshook))
|
||||
// disable
|
||||
if ($action == $acts[1])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||
else { $rowidcol="rowid"; }
|
||||
$rowidcol="rowid";
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
}
|
||||
elseif ($code) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
|
||||
}
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
@@ -475,7 +438,7 @@ if ($action == 'delete')
|
||||
//var_dump($elementList);
|
||||
|
||||
|
||||
$sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, content_lines, content, active";
|
||||
$sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, active";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates";
|
||||
$sql.=" WHERE entity IN (".getEntity('email_template').")";
|
||||
if (! $user->admin)
|
||||
@@ -541,11 +504,14 @@ foreach ($fieldlist as $field => $value)
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='content') { $valuetoshow=''; }
|
||||
if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
|
||||
if ($fieldlist[$field]=='private') { $align='center'; }
|
||||
if ($fieldlist[$field]=='position') { $align='center'; }
|
||||
|
||||
if ($fieldlist[$field]=='topic') { $valuetoshow=''; }
|
||||
if ($fieldlist[$field]=='joinfiles') { $valuetoshow=''; }
|
||||
if ($fieldlist[$field]=='content') { $valuetoshow=''; }
|
||||
if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
|
||||
|
||||
if ($valuetoshow != '')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
@@ -560,14 +526,11 @@ foreach ($fieldlist as $field => $value)
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
||||
}
|
||||
print '<td colspan="3">';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="' . $id . '">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Line to enter new values (input fields)
|
||||
print "<tr " . $bcnd[$var] . ">";
|
||||
|
||||
$obj = new stdClass();
|
||||
// If data was already input, we define them in obj to populate input fields.
|
||||
if (GETPOST('actionadd'))
|
||||
@@ -587,6 +550,10 @@ $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters,
|
||||
$error = $hookmanager->error;
|
||||
$errors = $hookmanager->errors;
|
||||
|
||||
|
||||
// Line to enter new values (input fields)
|
||||
print "<tr " . $bcnd[$var] . ">";
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
@@ -596,32 +563,51 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
print '<td align="right" colspan="3">';
|
||||
print '<td align="right">';
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
|
||||
$fieldsforcontent = array('content');
|
||||
$fieldsforcontent = array('topic', 'joinfiles', 'content');
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('content','content_lines'); }
|
||||
foreach ($fieldsforcontent as $tmpfieldlist)
|
||||
{
|
||||
print '<tr class="impair nodrag nodrop nohover"><td colspan="6">';
|
||||
print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
|
||||
// Label
|
||||
if ($tmpfieldlist == 'topic')
|
||||
{
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
|
||||
}
|
||||
if ($tmpfieldlist == 'joinfiles')
|
||||
{
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
|
||||
}
|
||||
if ($tmpfieldlist == 'content')
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong><br>';
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
|
||||
if ($tmpfieldlist == 'content_lines')
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong><br>';
|
||||
|
||||
if ($context != 'hide') {
|
||||
// print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
|
||||
$okforextended = true;
|
||||
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
|
||||
$okforextended = false;
|
||||
$doleditor = new DolEditor($tmpfieldlist, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
|
||||
print $doleditor->Create(1);
|
||||
} else
|
||||
print ' ';
|
||||
// Input field
|
||||
if ($tmpfieldlist == 'topic') {
|
||||
print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
|
||||
}
|
||||
else if ($tmpfieldlist == 'joinfiles') {
|
||||
print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($context != 'hide') {
|
||||
// print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
|
||||
$okforextended = true;
|
||||
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
|
||||
$okforextended = false;
|
||||
$doleditor = new DolEditor($tmpfieldlist, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
|
||||
print $doleditor->Create(1);
|
||||
}
|
||||
else
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
if ($tmpfieldlist == 'content') {
|
||||
print '<td align="center" colspan="3" rowspan="' . (count($fieldsforcontent)) . '">';
|
||||
if ($tmpfieldlist == 'topic') {
|
||||
print '<td align="center" rowspan="' . (count($fieldsforcontent)) . '">';
|
||||
if ($action != 'edit') {
|
||||
print '<input type="submit" class="button" name="actionadd" value="' . $langs->trans("Add") . '">';
|
||||
}
|
||||
@@ -704,7 +690,6 @@ if ($resql)
|
||||
elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="right" width="64">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
@@ -736,11 +721,13 @@ if ($resql)
|
||||
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;}
|
||||
if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; }
|
||||
if ($fieldlist[$field]=='private') { $align='center'; }
|
||||
if ($fieldlist[$field]=='position') { $align='center'; }
|
||||
|
||||
if ($fieldlist[$field]=='joinfiles') { $valuetoshow=$langs->trans("FilesAttachedToEmail"); $align='center'; }
|
||||
if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;}
|
||||
if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; }
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
@@ -755,7 +742,6 @@ if ($resql)
|
||||
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
@@ -777,7 +763,8 @@ if ($resql)
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
|
||||
|
||||
print '<td colspan="3" align="center">';
|
||||
print '<td></td><td></td><td></td>';
|
||||
print '<td align="center">';
|
||||
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").'">';
|
||||
@@ -785,10 +772,10 @@ if ($resql)
|
||||
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td>';
|
||||
|
||||
$fieldsforcontent = array('content');
|
||||
$fieldsforcontent = array('topic', 'joinfiles', 'content');
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
|
||||
{
|
||||
$fieldsforcontent = array('content', 'content_lines');
|
||||
$fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
|
||||
}
|
||||
foreach ($fieldsforcontent as $tmpfieldlist)
|
||||
{
|
||||
@@ -799,17 +786,29 @@ if ($resql)
|
||||
$class = 'tddict';
|
||||
// Show value for field
|
||||
if ($showfield) {
|
||||
|
||||
// Show line for topic, joinfiles and content
|
||||
print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' ">';
|
||||
print '<td colspan="7">'; // To create an artificial CR for the current tr we are on
|
||||
$okforextended = true;
|
||||
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
|
||||
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
|
||||
print $doleditor->Create(1);
|
||||
print '<td colspan="8">';
|
||||
if ($tmpfieldlist == 'topic')
|
||||
{
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
|
||||
print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
|
||||
}
|
||||
if ($tmpfieldlist == 'joinfiles')
|
||||
{
|
||||
print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
|
||||
print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
|
||||
}
|
||||
if ($tmpfieldlist == 'content')
|
||||
{
|
||||
$okforextended = true;
|
||||
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
|
||||
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
|
||||
print $doleditor->Create(1);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -856,6 +855,12 @@ if ($resql)
|
||||
{
|
||||
$align="center";
|
||||
}
|
||||
if ($value == 'joinfiles')
|
||||
{
|
||||
$align="center";
|
||||
if ($valuetoshow) $valuetoshow=1;
|
||||
else $valuetoshow='';
|
||||
}
|
||||
|
||||
$class='tddict';
|
||||
// Show value for field
|
||||
@@ -880,24 +885,21 @@ if ($resql)
|
||||
if ($param) $url .= '&'.$param;
|
||||
$url.='&';
|
||||
|
||||
// Active
|
||||
// Status / Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
print "</td>";
|
||||
|
||||
// Modify link
|
||||
if ($canbemodified) print '<td align="center" width="64"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
|
||||
else print '<td></td>';
|
||||
|
||||
// Delete link
|
||||
// Modify link / Delete link
|
||||
print '<td align="center" width="64">';
|
||||
if ($canbemodified) print '<a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a>';
|
||||
if ($iserasable)
|
||||
{
|
||||
print '<td align="center" width="64">';
|
||||
print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
|
||||
print ' <a href="'.$url.'action=delete">'.img_delete().'</a>';
|
||||
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
|
||||
print '</td>';
|
||||
}
|
||||
else print '<td></td>';
|
||||
print '</td>';
|
||||
|
||||
|
||||
/*
|
||||
$fieldsforcontent = array('content');
|
||||
@@ -1042,7 +1044,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
elseif (in_array($fieldlist[$field], array('content','content_lines'))) continue;
|
||||
elseif ($context == 'add' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||
elseif ($context == 'edit' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||
elseif ($context == 'hide' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||
else
|
||||
{
|
||||
$size=''; $class=''; $classtd='';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -54,7 +54,7 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
if (preg_match('/set_(.*)/',$action,$reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
$value=(GETPOST($code) ? GETPOST($code) : 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"]);
|
||||
@@ -82,10 +82,10 @@ else if (preg_match('/del_(.*)/',$action,$reg))
|
||||
|
||||
else if ($action == 'updateform')
|
||||
{
|
||||
$res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',$_POST["MAIN_UPLOAD_DOC"],'chaine',0,'',$conf->entity);
|
||||
$res4=dolibarr_set_const($db, "MAIN_UMASK", $_POST["MAIN_UMASK"],'chaine',0,'',$conf->entity);
|
||||
$res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", $_POST["MAIN_ANTIVIRUS_COMMAND"],'chaine',0,'',$conf->entity);
|
||||
$res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", $_POST["MAIN_ANTIVIRUS_PARAM"],'chaine',0,'',$conf->entity);
|
||||
$res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',GETPOST('MAIN_UPLOAD_DOC','alpha'),'chaine',0,'',$conf->entity);
|
||||
$res4=dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK','alpha'),'chaine',0,'',$conf->entity);
|
||||
$res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim(GETPOST('MAIN_ANTIVIRUS_COMMAND','none')),'chaine',0,'',$conf->entity); // Use GETPOST none because we must accept "
|
||||
$res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim(GETPOST('MAIN_ANTIVIRUS_PARAM','none')),'chaine',0,'',$conf->entity); // Use GETPOST none because we must accept "
|
||||
if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
|
||||
dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
|
||||
}
|
||||
}
|
||||
print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)?dol_htmlentities($conf->global->MAIN_ANTIVIRUS_COMMAND):'').'">';
|
||||
print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND):'').'">';
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
@@ -189,7 +189,7 @@ print '<td colspan="2">'.$langs->trans("AntiVirusParam").'<br>';
|
||||
print $langs->trans("AntiVirusParamExample");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_PARAM)?dol_htmlentities($conf->global->MAIN_ANTIVIRUS_PARAM):'').'">';
|
||||
print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_PARAM)?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM):'').'">';
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@@ -56,9 +56,14 @@ class DolibarrApi
|
||||
$this->db = $db;
|
||||
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
|
||||
$this->r = new Restler($production_mode, $refreshCache);
|
||||
|
||||
$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
|
||||
$this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot);
|
||||
|
||||
$urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT));
|
||||
$urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
|
||||
|
||||
$this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
|
||||
$this->r->setAPIVersion(1);
|
||||
}
|
||||
|
||||
@@ -131,6 +136,9 @@ class DolibarrApi
|
||||
unset($object->table_element_line);
|
||||
unset($object->picto);
|
||||
|
||||
unset($object->skip_update_total);
|
||||
unset($object->context);
|
||||
|
||||
// Remove the $oldcopy property because it is not supported by the JSON
|
||||
// encoder. The following error is generated when trying to serialize
|
||||
// it: "Error encoding/decoding JSON: Type is not supported"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
|
||||
|
||||
/**
|
||||
* API class for payment type (content of the paiement dictionary)
|
||||
* API class for dictionaries
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
@@ -47,13 +51,14 @@ class Dictionary extends DolibarrApi
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment type is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
|
||||
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')"
|
||||
*
|
||||
* @url GET payments
|
||||
* @url GET payment/types
|
||||
*
|
||||
* @return List of payment types
|
||||
*
|
||||
* @throws RestException
|
||||
* @return array [List of payment types]
|
||||
*
|
||||
* @throws 400 RestException
|
||||
* @throws 200 OK
|
||||
*/
|
||||
function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
@@ -67,9 +72,9 @@ class Dictionary extends DolibarrApi
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
@@ -94,7 +99,7 @@ class Dictionary extends DolibarrApi
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror());
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
@@ -447,6 +452,68 @@ class Dictionary extends DolibarrApi
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of payments terms.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment term is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
|
||||
*
|
||||
* @url GET payment/terms
|
||||
*
|
||||
* @return array List of payment terms
|
||||
*
|
||||
* @throws 400 RestException
|
||||
* @throws 200 OK
|
||||
*/
|
||||
function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
|
||||
$sql.= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use Luracast\Restler\Format\UploadFormat;
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
/**
|
||||
* API class for receive files
|
||||
@@ -32,85 +33,148 @@ require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
class Documents extends DolibarrApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $DOCUMENT_FIELDS = array(
|
||||
'modulepart'
|
||||
);
|
||||
/**
|
||||
* @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $DOCUMENT_FIELDS = array(
|
||||
'modulepart'
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return list of documents.
|
||||
*
|
||||
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
|
||||
* @param string $ref Reference of object (This will define subdir automatically)
|
||||
* @param string $subdir Subdirectory (Only if ref not provided)
|
||||
* @return array List of documents
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($module_part, $ref='', $subdir='') {
|
||||
return array('note'=>'FeatureNotYetAvailable');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a document.
|
||||
*
|
||||
* @param int $id ID of document
|
||||
* @return array Array with data of file
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
/*
|
||||
|
||||
/**
|
||||
* Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download
|
||||
* a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie).
|
||||
*
|
||||
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
|
||||
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf)
|
||||
* @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases.
|
||||
* Also, note that setting this to 1 nead write access on object.
|
||||
* @return array List of documents
|
||||
*
|
||||
* @throws 500
|
||||
* @throws 501
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 200
|
||||
*/
|
||||
public function index($module_part, $original_file='', $regeneratedoc=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (empty($module_part)) {
|
||||
throw new RestException(400, 'bad value for parameter modulepart');
|
||||
}
|
||||
if (empty($original_file)) {
|
||||
throw new RestException(400, 'bad value for parameter ref or subdir');
|
||||
}
|
||||
|
||||
//--- Finds and returns the document
|
||||
$entity=$conf->entity;
|
||||
|
||||
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', ($regeneratedoc ? 'write' : 'read'));
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$original_file = $check_access['original_file'];
|
||||
|
||||
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
|
||||
{
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!$accessallowed) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
// --- Generates the document
|
||||
if ($regeneratedoc)
|
||||
{
|
||||
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
|
||||
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
|
||||
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
|
||||
|
||||
if ($module_part == 'facture' || $module_part == 'invoice')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$this->invoice = new Facture($this->db);
|
||||
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
$result = $this->invoice->generateDocument($this->invoice->modelpdf, $langs, $hidedetails, $hidedesc, $hideref);
|
||||
if( $result <= 0 ) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filename = basename($original_file);
|
||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||
|
||||
if (! file_exists($original_file_osencoded))
|
||||
{
|
||||
throw new RestException(404, 'File not found');
|
||||
}
|
||||
|
||||
$file_content=file_get_contents($original_file_osencoded);
|
||||
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a document.
|
||||
*
|
||||
* @param int $id ID of document
|
||||
* @return array Array with data of file
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
/*
|
||||
public function get($id) {
|
||||
return array('note'=>'xxx');
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* Push a file.
|
||||
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
*
|
||||
* @param string $filename Name of file to create ('FA1705-0123')
|
||||
* @param string $modulepart Name of module or area concerned by file upload ('facture', ...)
|
||||
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
|
||||
* @param string $subdir Subdirectory (Only if ref not provided)
|
||||
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
|
||||
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @return bool State of copy
|
||||
* @throws RestException
|
||||
*/
|
||||
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
/*var_dump($modulepart);
|
||||
|
||||
|
||||
/**
|
||||
* Push a file.
|
||||
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
*
|
||||
* @param string $filename Name of file to create ('FA1705-0123')
|
||||
* @param string $modulepart Name of module or area concerned by file upload ('facture', ...)
|
||||
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
|
||||
* @param string $subdir Subdirectory (Only if ref not provided)
|
||||
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
|
||||
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @return bool State of copy
|
||||
* @throws RestException
|
||||
*/
|
||||
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
/*var_dump($modulepart);
|
||||
var_dump($filename);
|
||||
var_dump($filecontent);
|
||||
exit;*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$newfilecontent = '';
|
||||
if (empty($fileencoding)) $newfilecontent = $filecontent;
|
||||
if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent);
|
||||
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$newfilecontent = '';
|
||||
if (empty($fileencoding)) $newfilecontent = $filecontent;
|
||||
if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent);
|
||||
|
||||
$original_file = dol_sanitizeFileName($filename);
|
||||
|
||||
@@ -119,86 +183,86 @@ class Documents extends DolibarrApi
|
||||
$entity = $user->entity;
|
||||
if ($ref)
|
||||
{
|
||||
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||
{
|
||||
$modulepart='facture';
|
||||
$object=new Facture($db);
|
||||
$result = $object->fetch('', $ref);
|
||||
}
|
||||
|
||||
if (! ($object->id > 0))
|
||||
{
|
||||
throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found.");
|
||||
}
|
||||
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||
{
|
||||
$modulepart='facture';
|
||||
$object=new Facture($db);
|
||||
$result = $object->fetch('', $ref);
|
||||
}
|
||||
|
||||
$tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
|
||||
if (empty($upload_dir) || $upload_dir == '/')
|
||||
{
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
}
|
||||
if (! ($object->id > 0))
|
||||
{
|
||||
throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found.");
|
||||
}
|
||||
|
||||
$tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
|
||||
if (empty($upload_dir) || $upload_dir == '/')
|
||||
{
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modulepart == 'invoice') $modulepart ='facture';
|
||||
|
||||
$tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
if ($modulepart == 'invoice') $modulepart ='facture';
|
||||
|
||||
if (empty($upload_dir) || $upload_dir == '/')
|
||||
{
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
}
|
||||
$tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
|
||||
if (empty($upload_dir) || $upload_dir == '/')
|
||||
{
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$upload_dir = dol_sanitizePathName($upload_dir);
|
||||
|
||||
|
||||
$destfile = $upload_dir . '/' . $original_file;
|
||||
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file;
|
||||
dol_delete_file($destfiletmp);
|
||||
|
||||
if (!dol_is_dir($upload_dir)) {
|
||||
throw new RestException(401,'Directory not exists : '.$upload_dir);
|
||||
}
|
||||
|
||||
if (! $overwriteifexists && dol_is_file($destfile))
|
||||
{
|
||||
throw new RestException(500, "File with name '".$original_file."' already exists.");
|
||||
}
|
||||
|
||||
$fhandle = @fopen($destfiletmp, 'w');
|
||||
if ($fhandle)
|
||||
{
|
||||
$nbofbyteswrote = fwrite($fhandle, $newfilecontent);
|
||||
fclose($fhandle);
|
||||
@chmod($destfiletmp, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RestException(500, "Failed to open file '".$destfiletmp."' for write");
|
||||
}
|
||||
|
||||
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
if (!dol_is_dir($upload_dir)) {
|
||||
throw new RestException(401,'Directory not exists : '.$upload_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
* @param array $data Array with data to verify
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate_file($data) {
|
||||
$result = array();
|
||||
foreach (Documents::$DOCUMENT_FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$result[$field] = $data[$field];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
if (! $overwriteifexists && dol_is_file($destfile))
|
||||
{
|
||||
throw new RestException(500, "File with name '".$original_file."' already exists.");
|
||||
}
|
||||
|
||||
$fhandle = @fopen($destfiletmp, 'w');
|
||||
if ($fhandle)
|
||||
{
|
||||
$nbofbyteswrote = fwrite($fhandle, $newfilecontent);
|
||||
fclose($fhandle);
|
||||
@chmod($destfiletmp, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RestException(500, "Failed to open file '".$destfiletmp."' for write");
|
||||
}
|
||||
|
||||
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
* @param array $data Array with data to verify
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate_file($data) {
|
||||
$result = array();
|
||||
foreach (Documents::$DOCUMENT_FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$result[$field] = $data[$field];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ switch ($action)
|
||||
$cond_reglement_id = 0;
|
||||
break;
|
||||
case 'ESP':
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement');
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement','code','id',1);
|
||||
$cond_reglement_id = 0;
|
||||
$note .= $langs->trans("Cash")."\n";
|
||||
$note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n";
|
||||
@@ -145,11 +145,11 @@ switch ($action)
|
||||
$note .= '--------------------------------------'."\n\n";
|
||||
break;
|
||||
case 'CB':
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement');
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'CB','c_paiement','code','id',1);
|
||||
$cond_reglement_id = 0;
|
||||
break;
|
||||
case 'CHQ':
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement');
|
||||
$mode_reglement_id = dol_getIdFromCode($db,'CHQ','c_paiement','code','id',1);
|
||||
$cond_reglement_id = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
/**
|
||||
* API class for categories
|
||||
*
|
||||
* @access protected
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class Categories extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'label',
|
||||
@@ -44,7 +44,7 @@ class Categories extends DolibarrApi
|
||||
4 => 'contact',
|
||||
5 => 'account',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* @var Categorie $category {@type Categorie}
|
||||
*/
|
||||
@@ -67,20 +67,20 @@ class Categories extends DolibarrApi
|
||||
*
|
||||
* @param int $id ID of category
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->category->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class Categories extends DolibarrApi
|
||||
|
||||
/**
|
||||
* List categories
|
||||
*
|
||||
*
|
||||
* Get a list of categories
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
@@ -105,13 +105,13 @@ class Categories extends DolibarrApi
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type = '', $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('category').')';
|
||||
@@ -120,7 +120,7 @@ class Categories extends DolibarrApi
|
||||
$sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@@ -129,93 +129,6 @@ class Categories extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i=0;
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$category_static = new Categorie($db);
|
||||
if($category_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($category_static);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* List categories of an entity
|
||||
*
|
||||
* Note: This method is not directly exposed in the API, it is used
|
||||
* in the GET /xxx/{id}/categories requests.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param int $item Id of the item to get categories for
|
||||
* @return array Array of category objects
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function getListForItem($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type='customer', $item = 0) {
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
//if ($type == "") {
|
||||
//$type="product";
|
||||
//}
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer" || $type=="supplier") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
}
|
||||
$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='.array_search($type,Categories::$TYPES);
|
||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
@@ -250,13 +163,12 @@ class Categories extends DolibarrApi
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create category object
|
||||
*
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of category
|
||||
*/
|
||||
@@ -268,7 +180,7 @@ class Categories extends DolibarrApi
|
||||
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->category->$field = $value;
|
||||
}
|
||||
@@ -280,22 +192,22 @@ class Categories extends DolibarrApi
|
||||
|
||||
/**
|
||||
* Update category
|
||||
*
|
||||
*
|
||||
* @param int $id Id of category to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->category->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@@ -304,13 +216,13 @@ class Categories extends DolibarrApi
|
||||
if ($field == 'id') continue;
|
||||
$this->category->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->category->update(DolibarrApiAccess::$user))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete category
|
||||
*
|
||||
@@ -326,15 +238,15 @@ class Categories extends DolibarrApi
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
if (! $this->category->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401,'error when delete category');
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
@@ -342,8 +254,8 @@ class Categories extends DolibarrApi
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
@@ -351,9 +263,9 @@ class Categories extends DolibarrApi
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
|
||||
// Remove fields not relevent to categories
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
@@ -394,16 +306,16 @@ class Categories extends DolibarrApi
|
||||
unset($object->fk_project);
|
||||
unset($object->note);
|
||||
unset($object->statut);
|
||||
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
|
||||
@@ -879,6 +879,100 @@ class Categorie extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List categories of an element id
|
||||
*
|
||||
* @param int $id Id of element
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @return array Array of categories
|
||||
*/
|
||||
function getListForItem($id, $type='customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$categories = array();
|
||||
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer" || $type=="supplier") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
}
|
||||
$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='.array_search($type, self::$MAP_ID_TO_CODE);
|
||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql.= ' AND sub.'.$subcol_name.' = '.$id;
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $this->db->query($sql);
|
||||
$nbtotalofrecords = $this->db->num_rows($result);
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i=0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$category_static = new Categorie($this->db);
|
||||
if ($category_static->fetch($obj->rowid))
|
||||
{
|
||||
$categories[$i]['id'] = $category_static->id;
|
||||
$categories[$i]['fk_parent'] = $category_static->fk_parent;
|
||||
$categories[$i]['label'] = $category_static->label;
|
||||
$categories[$i]['description'] = $category_static->description;
|
||||
$categories[$i]['color'] = $category_static->color;
|
||||
$categories[$i]['socid'] = $category_static->socid;
|
||||
$categories[$i]['visible'] = $category_static->visible;
|
||||
$categories[$i]['type'] = $category_static->type;
|
||||
$categories[$i]['entity'] = $category_static->entity;
|
||||
$categories[$i]['array_options'] = $category_static->array_options;
|
||||
|
||||
// multilangs
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$categories[$i]['multilangs'] = $category_static->multilangs;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
if ( ! count($categories)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return childs of a category
|
||||
*
|
||||
|
||||
@@ -319,7 +319,7 @@ else
|
||||
|
||||
|
||||
// List of products or services (type is type of category)
|
||||
if ($object->type == Categorie::TYPE_PRODUCT)
|
||||
if ($type == Categorie::TYPE_PRODUCT)
|
||||
{
|
||||
$prods = $object->getObjectsInCateg("product");
|
||||
if ($prods < 0)
|
||||
@@ -391,7 +391,7 @@ if ($object->type == Categorie::TYPE_PRODUCT)
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->type == Categorie::TYPE_SUPPLIER)
|
||||
if ($type == Categorie::TYPE_SUPPLIER)
|
||||
{
|
||||
$socs = $object->getObjectsInCateg("supplier");
|
||||
if ($socs < 0)
|
||||
@@ -440,7 +440,7 @@ if ($object->type == Categorie::TYPE_SUPPLIER)
|
||||
}
|
||||
}
|
||||
|
||||
if($object->type == Categorie::TYPE_CUSTOMER)
|
||||
if($type == Categorie::TYPE_CUSTOMER)
|
||||
{
|
||||
$socs = $object->getObjectsInCateg("customer");
|
||||
if ($socs < 0)
|
||||
@@ -494,7 +494,7 @@ if($object->type == Categorie::TYPE_CUSTOMER)
|
||||
}
|
||||
|
||||
// List of members
|
||||
if ($object->type == Categorie::TYPE_MEMBER)
|
||||
if ($type == Categorie::TYPE_MEMBER)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
@@ -547,7 +547,7 @@ if ($object->type == Categorie::TYPE_MEMBER)
|
||||
}
|
||||
|
||||
// Categorie contact
|
||||
if($object->type == Categorie::TYPE_CONTACT)
|
||||
if ($type == Categorie::TYPE_CONTACT)
|
||||
{
|
||||
$contacts = $object->getObjectsInCateg("contact");
|
||||
if ($contacts < 0)
|
||||
@@ -600,7 +600,7 @@ if($object->type == Categorie::TYPE_CONTACT)
|
||||
}
|
||||
|
||||
// List of accounts
|
||||
if ($object->type == Categorie::TYPE_ACCOUNT)
|
||||
if ($type == Categorie::TYPE_ACCOUNT)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
@@ -653,7 +653,7 @@ if ($object->type == Categorie::TYPE_ACCOUNT)
|
||||
}
|
||||
|
||||
// List of Project
|
||||
if ($object->type == Categorie::TYPE_PROJECT)
|
||||
if ($type == Categorie::TYPE_PROJECT)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
|
||||
@@ -907,59 +907,66 @@ class ActionComm extends CommonObject
|
||||
return $db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @param User $user Objet user
|
||||
* @param int $load_state_board Charge indicateurs this->nb de tableau de bord
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user)
|
||||
function load_board($user, $load_state_board=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$sql = "SELECT a.id, a.datep as dp";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= ")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
|
||||
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
||||
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
||||
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$agenda_static = new ActionComm($this->db);
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("ActionsToDo");
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
|
||||
if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1';
|
||||
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
|
||||
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
|
||||
$agenda_static->datep = $this->db->jdate($obj->dp);
|
||||
|
||||
if ($agenda_static->hasDelay()) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
global $conf, $langs;
|
||||
|
||||
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
|
||||
else {
|
||||
$this->nb=array();
|
||||
$sql = "SELECT count(a.id) as nb";
|
||||
}
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= ")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql.= " WHERE 1";
|
||||
if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100";
|
||||
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
||||
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
||||
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if(empty($load_state_board)) {
|
||||
$agenda_static = new ActionComm($this->db);
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("ActionsToDo");
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
|
||||
if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1';
|
||||
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
|
||||
}
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
if(empty($load_state_board)) {
|
||||
$response->nbtodo++;
|
||||
$agenda_static->datep = $this->db->jdate($obj->dp);
|
||||
if ($agenda_static->hasDelay()) $response->nbtodolate++;
|
||||
} else $this->nb["actionscomm"]=$obj->nb;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
if(empty($load_state_board)) return $response;
|
||||
else return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ if ($resql)
|
||||
//$param='month='.$monthshown.'&year='.$year;
|
||||
$hourminsec='100000';
|
||||
$link = '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
|
||||
$link.= $langs->trans("NewAction");
|
||||
$link.= $langs->trans("AddAction");
|
||||
$link.= '</a>';
|
||||
}
|
||||
|
||||
@@ -372,9 +372,9 @@ if ($resql)
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"><input type="text" name="search_title" value="'.$search_title.'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
@@ -396,9 +396,9 @@ if ($resql)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateStart",$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
|
||||
@@ -452,11 +452,6 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// Label
|
||||
print '<td class="tdoverflowmax300">';
|
||||
print $actionstatic->label;
|
||||
print '</td>';
|
||||
|
||||
// Type
|
||||
print '<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
@@ -475,6 +470,11 @@ if ($resql)
|
||||
print dol_trunc($labeltype,28);
|
||||
print '</td>';
|
||||
|
||||
// Label
|
||||
print '<td class="tdoverflowmax300">';
|
||||
print $actionstatic->label;
|
||||
print '</td>';
|
||||
|
||||
// Start date
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->dp),"dayhour");
|
||||
|
||||
@@ -116,7 +116,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
|
||||
print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
|
||||
@@ -231,8 +231,8 @@ if (empty($reshook))
|
||||
|
||||
// Validation
|
||||
else if ($action == 'confirm_validate' && $confirm == 'yes' &&
|
||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
|
||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
|
||||
)
|
||||
{
|
||||
$result = $object->valid($user);
|
||||
@@ -294,15 +294,15 @@ if (empty($reshook))
|
||||
$result = $object->set_ref_client($user, GETPOST('ref_client'));
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Set incoterm
|
||||
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
|
||||
{
|
||||
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
|
||||
}
|
||||
{
|
||||
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
|
||||
}
|
||||
|
||||
// Create proposal
|
||||
else if ($action == 'add' && $user->rights->propal->creer)
|
||||
@@ -346,11 +346,11 @@ if (empty($reshook))
|
||||
$object->availability_id = GETPOST('availability_id');
|
||||
$object->demand_reason_id = GETPOST('demand_reason_id');
|
||||
$object->fk_delivery_address = GETPOST('fk_address');
|
||||
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
|
||||
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
|
||||
$object->duree_validite = $duration;
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->remise_percent = GETPOST('remise_percent');
|
||||
$object->remise_absolue = GETPOST('remise_absolue');
|
||||
$object->socid = GETPOST('socid');
|
||||
@@ -377,11 +377,11 @@ if (empty($reshook))
|
||||
$object->availability_id = GETPOST('availability_id');
|
||||
$object->demand_reason_id = GETPOST('demand_reason_id');
|
||||
$object->fk_delivery_address = GETPOST('fk_address');
|
||||
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
|
||||
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
|
||||
$object->duree_validite = GETPOST('duree_validite');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->contactid = GETPOST('contactid');
|
||||
$object->fk_project = GETPOST('projectid');
|
||||
$object->modelpdf = GETPOST('model');
|
||||
@@ -527,7 +527,7 @@ if (empty($reshook))
|
||||
// Hooks
|
||||
$parameters = array('objFrom' => $srcobject);
|
||||
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
// modified by hook
|
||||
// modified by hook
|
||||
if ($reshook < 0)
|
||||
$error ++;
|
||||
} else {
|
||||
@@ -561,23 +561,23 @@ if (empty($reshook))
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$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 = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$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 = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0) dol_print_error($db,$result);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0) dol_print_error($db,$result);
|
||||
}
|
||||
|
||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
||||
exit();
|
||||
@@ -647,7 +647,7 @@ if (empty($reshook))
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
// Actions to send emails
|
||||
$actiontypecode='AC_OTH_AUTO';
|
||||
$actiontypecode='AC_OTH_AUTO';
|
||||
$trigger_name='PROPAL_SENTBYMAIL';
|
||||
$autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
|
||||
$trackid='pro'.$object->id;
|
||||
@@ -756,7 +756,7 @@ if (empty($reshook))
|
||||
|
||||
$db->begin();
|
||||
|
||||
// $tva_tx can be 'x.x (XXX)'
|
||||
// $tva_tx can be 'x.x (XXX)'
|
||||
|
||||
// Ecrase $pu par celui du produit
|
||||
// Ecrase $desc par celui du produit
|
||||
@@ -781,7 +781,7 @@ if (empty($reshook))
|
||||
// On defini prix unitaire
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
|
||||
{
|
||||
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
|
||||
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
|
||||
@@ -801,7 +801,7 @@ if (empty($reshook))
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
// If there is some prices specific to the customer
|
||||
// If there is some prices specific to the customer
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
@@ -949,18 +949,18 @@ if (empty($reshook))
|
||||
unset($_POST['idprod']);
|
||||
unset($_POST['units']);
|
||||
|
||||
unset($_POST['date_starthour']);
|
||||
unset($_POST['date_startmin']);
|
||||
unset($_POST['date_startsec']);
|
||||
unset($_POST['date_startday']);
|
||||
unset($_POST['date_startmonth']);
|
||||
unset($_POST['date_startyear']);
|
||||
unset($_POST['date_endhour']);
|
||||
unset($_POST['date_endmin']);
|
||||
unset($_POST['date_endsec']);
|
||||
unset($_POST['date_endday']);
|
||||
unset($_POST['date_endmonth']);
|
||||
unset($_POST['date_endyear']);
|
||||
unset($_POST['date_starthour']);
|
||||
unset($_POST['date_startmin']);
|
||||
unset($_POST['date_startsec']);
|
||||
unset($_POST['date_startday']);
|
||||
unset($_POST['date_startmonth']);
|
||||
unset($_POST['date_startyear']);
|
||||
unset($_POST['date_endhour']);
|
||||
unset($_POST['date_endmin']);
|
||||
unset($_POST['date_endsec']);
|
||||
unset($_POST['date_endday']);
|
||||
unset($_POST['date_endmonth']);
|
||||
unset($_POST['date_endyear']);
|
||||
} else {
|
||||
$db->rollback();
|
||||
|
||||
@@ -1159,12 +1159,12 @@ if (empty($reshook))
|
||||
|
||||
// bank account
|
||||
else if ($action == 'setbankaccount' && $user->rights->propal->creer) {
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
}
|
||||
|
||||
// shipping method
|
||||
else if ($action == 'setshippingmethod' && $user->rights->propal->creer) {
|
||||
$result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
|
||||
$result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'update_extras') {
|
||||
@@ -1225,10 +1225,10 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->propal->dir_output;
|
||||
$permissioncreate=$user->rights->propal->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->propal->dir_output;
|
||||
$permissioncreate=$user->rights->propal->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
}
|
||||
|
||||
@@ -1252,7 +1252,7 @@ $now = dol_now();
|
||||
// Add new proposal
|
||||
if ($action == 'create')
|
||||
{
|
||||
$currency_code = $conf->currency;
|
||||
$currency_code = $conf->currency;
|
||||
|
||||
print load_fiche_titre($langs->trans("NewProp"));
|
||||
|
||||
@@ -1317,14 +1317,14 @@ if ($action == 'create')
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
|
||||
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
|
||||
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
|
||||
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
|
||||
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
|
||||
}
|
||||
|
||||
$object = new Propal($db);
|
||||
@@ -1359,9 +1359,9 @@ if ($action == 'create')
|
||||
print $soc->getNomUrl(1);
|
||||
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
|
||||
print '</td>';
|
||||
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) {
|
||||
$shipping_method_id = $soc->shipping_method_id;
|
||||
}
|
||||
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) {
|
||||
$shipping_method_id = $soc->shipping_method_id;
|
||||
}
|
||||
} else {
|
||||
print '<td>';
|
||||
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
|
||||
@@ -1427,12 +1427,12 @@ if ($action == 'create')
|
||||
$form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Bank Account
|
||||
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// What trigger creation
|
||||
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
|
||||
@@ -1444,12 +1444,12 @@ if ($action == 'create')
|
||||
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Shipping Method
|
||||
if (! empty($conf->expedition->enabled)) {
|
||||
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
|
||||
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Shipping Method
|
||||
if (! empty($conf->expedition->enabled)) {
|
||||
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
|
||||
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Delivery date (or manufacturing)
|
||||
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
|
||||
@@ -1485,8 +1485,8 @@ if ($action == 'create')
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).'</label></td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -1503,8 +1503,8 @@ if ($action == 'create')
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -1522,7 +1522,7 @@ if ($action == 'create')
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
|
||||
print '<td valign="top">';
|
||||
$note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
|
||||
$note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
|
||||
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
|
||||
print $doleditor->Create(1);
|
||||
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
|
||||
@@ -1587,7 +1587,7 @@ if ($action == 'create')
|
||||
|
||||
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE))
|
||||
{
|
||||
print '<br><table>';
|
||||
print '<br><table>';
|
||||
|
||||
// For backward compatibility
|
||||
print '<tr>';
|
||||
@@ -1690,7 +1690,15 @@ if ($action == 'create')
|
||||
//array('type' => 'other','name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '<textarea cols="30" rows="' . ROWS_3 . '" wrap="soft" name="note_private" id="note_private">'.$object->note_private.'</textarea>'));
|
||||
array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => $object->note_private));
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), '', 'setstatut', $formquestion, '', 1, 250);
|
||||
if (! empty($conf->notification->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
|
||||
$notify = new Notify($db);
|
||||
$formquestion = array_merge($formquestion, array(
|
||||
array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)),
|
||||
));
|
||||
}
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250);
|
||||
|
||||
}
|
||||
|
||||
@@ -1757,50 +1765,50 @@ if ($action == 'create')
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherProposals").'</a>)';
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->propal->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->propal->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@@ -1933,24 +1941,24 @@ if ($action == 'create')
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Shipping Method
|
||||
if (! empty($conf->expedition->enabled)) {
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('SendingMethod');
|
||||
print '</td>';
|
||||
if ($action != 'editshippingmethod' && $user->rights->propal->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editshippingmethod') {
|
||||
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
|
||||
} else {
|
||||
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Shipping Method
|
||||
if (! empty($conf->expedition->enabled)) {
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('SendingMethod');
|
||||
print '</td>';
|
||||
if ($action != 'editshippingmethod' && $user->rights->propal->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editshippingmethod') {
|
||||
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
|
||||
} else {
|
||||
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Origin of demand
|
||||
print '<tr><td>';
|
||||
@@ -2046,36 +2054,36 @@ if ($action == 'create')
|
||||
|
||||
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled))
|
||||
{
|
||||
// Bank Account
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('BankAccount');
|
||||
print '</td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->propal->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
// Bank Account
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('BankAccount');
|
||||
print '</td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->propal->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('IncotermLabel');
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('IncotermLabel');
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($action != 'editincoterm')
|
||||
{
|
||||
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
||||
@@ -2084,7 +2092,7 @@ if ($action == 'create')
|
||||
{
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
@@ -2097,25 +2105,25 @@ if ($action == 'create')
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
|
||||
@@ -2130,15 +2138,15 @@ if ($action == 'create')
|
||||
// Amount Local Taxes
|
||||
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
|
||||
{
|
||||
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
|
||||
print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
|
||||
print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2
|
||||
{
|
||||
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
|
||||
print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
|
||||
print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Amount TTC
|
||||
@@ -2154,7 +2162,7 @@ if ($action == 'create')
|
||||
// Margin Infos
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
$formmargin->displayMarginInfos($object);
|
||||
$formmargin->displayMarginInfos($object);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
@@ -2193,7 +2201,7 @@ if ($action == 'create')
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
|
||||
if (! empty($object->lines))
|
||||
@@ -2215,7 +2223,7 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print "</form>\n";
|
||||
|
||||
@@ -2229,7 +2237,7 @@ if ($action == 'create')
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
// modified by hook
|
||||
// modified by hook
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($action != 'editline')
|
||||
@@ -2237,12 +2245,12 @@ if ($action == 'create')
|
||||
// Validate
|
||||
if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
|
||||
{
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
|
||||
{
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=validate">' . $langs->trans('Validate') . '</a></div>';
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Validate') . '</a></div>';
|
||||
}
|
||||
// Create event
|
||||
|
||||
@@ -30,482 +30,518 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
class Proposals extends DolibarrApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'socid'
|
||||
);
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'socid'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var propal $propal {@type propal}
|
||||
*/
|
||||
public $propal;
|
||||
/**
|
||||
* @var propal $propal {@type propal}
|
||||
*/
|
||||
public $propal;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
$this->propal = new Propal($this->db);
|
||||
}
|
||||
$this->propal = new Propal($this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a commercial proposal object
|
||||
*
|
||||
* Return an array with commercial proposal informations
|
||||
*
|
||||
* @param int $id ID of commercial proposal
|
||||
* @return array|mixed data without useless information
|
||||
/**
|
||||
* Get properties of a commercial proposal object
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
* Return an array with commercial proposal informations
|
||||
*
|
||||
* @param int $id ID of commercial proposal
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->propal->fetchObjectLinked();
|
||||
$this->propal->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->propal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List commercial proposals
|
||||
*
|
||||
* Get a list of commercial proposals
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
||||
* @return array Array of order objects
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
/**
|
||||
* List commercial proposals
|
||||
*
|
||||
* Get a list of commercial proposals
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
||||
* @return array Array of order objects
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
$obj_ret = array();
|
||||
|
||||
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
|
||||
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
|
||||
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
|
||||
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
|
||||
|
||||
// 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 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;
|
||||
|
||||
$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."propal as t";
|
||||
$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."propal 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
|
||||
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.= ' WHERE t.entity IN ('.getEntity('propal').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||
if ($socids) $sql.= " AND t.fk_soc 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)
|
||||
{
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($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).")";
|
||||
}
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||
if ($socids) $sql.= " AND t.fk_soc 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)
|
||||
{
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($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).")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$propal_static = new Propal($db);
|
||||
if($propal_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($propal_static);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No order found');
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$propal_static = new Propal($db);
|
||||
if($propal_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($propal_static);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No order found');
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create commercial proposal object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of propal
|
||||
*/
|
||||
function post($request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
/**
|
||||
* Create commercial proposal object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of propal
|
||||
*/
|
||||
function post($request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401, "Insuffisant rights");
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->propal->$field = $value;
|
||||
}
|
||||
/*if (isset($request_data["lines"])) {
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->propal->$field = $value;
|
||||
}
|
||||
/*if (isset($request_data["lines"])) {
|
||||
$lines = array();
|
||||
foreach ($request_data["lines"] as $line) {
|
||||
array_push($lines, (object) $line);
|
||||
}
|
||||
$this->propal->lines = $lines;
|
||||
}*/
|
||||
if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
|
||||
}
|
||||
if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
|
||||
}
|
||||
|
||||
return $this->propal->id;
|
||||
}
|
||||
return $this->propal->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lines of a commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal
|
||||
*
|
||||
* @url GET {id}/lines
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getLines($id) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->lire) {
|
||||
/**
|
||||
* Get lines of a commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal
|
||||
*
|
||||
* @url GET {id}/lines
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getLines($id) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->propal->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->propal->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
$this->propal->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->propal->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line to given commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param array $request_data Commercial proposal line data
|
||||
*
|
||||
* @url POST {id}/lines
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function postLine($id, $request_data = NULL) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
/**
|
||||
* Add a line to given commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param array $request_data Commercial proposal line data
|
||||
*
|
||||
* @url POST {id}/lines
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function postLine($id, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if (! $result) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->propal->addline(
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
$request_data->fk_product,
|
||||
$request_data->remise_percent,
|
||||
'HT',
|
||||
0,
|
||||
$request_data->info_bits,
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$this->element,
|
||||
$request_data->id,
|
||||
$request_data->pu_ht_devise,
|
||||
$request_data->fk_remise_except
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
return $this->get($id)->line->rowid;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a line of given commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param int $lineid Id of line to update
|
||||
* @param array $request_data Commercial proposal line data
|
||||
*
|
||||
* @url PUT {id}/lines/{lineid}
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function putLine($id, $lineid, $request_data = NULL) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->propal->updateline(
|
||||
$lineid,
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->remise_percent,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
'HT',
|
||||
$request_data->info_bits,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->fk_parent_line,
|
||||
0,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->special_code,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
$result = $this->get($id);
|
||||
unset($result->line);
|
||||
return $this->_cleanObjectDatas($result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a line of given commercial proposal
|
||||
*
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param int $lineid Id of line to delete
|
||||
*
|
||||
* @url DELETE {id}/lines/{lineid}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function delLine($id, $lineid) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->propal->deleteline($lineid);
|
||||
if ($updateRes == 1) {
|
||||
return $this->get($id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update commercial proposal general fields (won't touch lines of commercial proposal)
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param array $request_data Datas
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id))
|
||||
{
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
foreach($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
$this->propal->$field = $value;
|
||||
}
|
||||
|
||||
if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||
return $this->get($id);
|
||||
$request_data = (object) $request_data;
|
||||
|
||||
return false;
|
||||
}
|
||||
$updateRes = $this->propal->addline(
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
$request_data->fk_product,
|
||||
$request_data->remise_percent,
|
||||
'HT',
|
||||
0,
|
||||
$request_data->info_bits,
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$this->element,
|
||||
$request_data->id,
|
||||
$request_data->multicurrency_subprice,
|
||||
$request_data->fk_remise_except
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete commercial proposal
|
||||
*
|
||||
* @param int $id Commercial proposal ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->supprimer) {
|
||||
if ($updateRes > 0) {
|
||||
return $this->get($id)->line->rowid;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a line of given commercial proposal
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param int $lineid Id of line to update
|
||||
* @param array $request_data Commercial proposal line data
|
||||
*
|
||||
* @url PUT {id}/lines/{lineid}
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function putLine($id, $lineid, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if($result <= 0) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$request_data = (object) $request_data;
|
||||
|
||||
$propalline = new PropaleLigne($this->db);
|
||||
$result = $propalline->fetch($lineid);
|
||||
if ($result <= 0) {
|
||||
throw new RestException(404, 'Proposal line not found');
|
||||
}
|
||||
|
||||
$updateRes = $this->propal->updateline(
|
||||
$lineid,
|
||||
isset($request_data->subprice)?$request_data->subprice:$propalline->subprice,
|
||||
isset($request_data->qty)?$request_data->qty:$propalline->qty,
|
||||
isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent,
|
||||
isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx,
|
||||
isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx,
|
||||
isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx,
|
||||
isset($request_data->desc)?$request_data->desc:$propalline->desc,
|
||||
'HT',
|
||||
isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits,
|
||||
isset($request_data->special_code)?$request_data->special_code:$propalline->special_code,
|
||||
isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line,
|
||||
0,
|
||||
isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice,
|
||||
isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht,
|
||||
isset($request_data->label)?$request_data->label:$propalline->label,
|
||||
isset($request_data->product_type)?$request_data->product_type:$propalline->product_type,
|
||||
isset($request_data->date_start)?$request_data->date_start:$propalline->date_start,
|
||||
isset($request_data->date_end)?$request_data->date_end:$propalline->date_end,
|
||||
isset($request_data->array_options)?$request_data->array_options:$propalline->array_options,
|
||||
isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit,
|
||||
isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
$result = $this->get($id);
|
||||
unset($result->line);
|
||||
return $this->_cleanObjectDatas($result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a line of given commercial proposal
|
||||
*
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param int $lineid Id of line to delete
|
||||
*
|
||||
* @url DELETE {id}/lines/{lineid}
|
||||
*
|
||||
* @return int
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
*/
|
||||
function deleteLine($id, $lineid) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->propal->deleteline($lineid);
|
||||
if ($updateRes > 0) {
|
||||
return $this->get($id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update commercial proposal general fields (won't touch lines of commercial proposal)
|
||||
*
|
||||
* @param int $id Id of commercial proposal to update
|
||||
* @param array $request_data Datas
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL) {
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
foreach($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
$this->propal->$field = $value;
|
||||
}
|
||||
|
||||
if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
|
||||
}
|
||||
if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||
return $this->get($id);
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Commercial Proposal deleted'
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a commercial proposal
|
||||
*
|
||||
* @param int $id Commercial proposal ID
|
||||
* @param int $notrigger Use {}
|
||||
*
|
||||
* @url POST {id}/validate
|
||||
*
|
||||
* @return array
|
||||
* FIXME An error 403 is returned if the request has an empty body.
|
||||
* Error message: "Forbidden: Content type `text/plain` is not supported."
|
||||
* Workaround: send this in the body
|
||||
* {
|
||||
* "notrigger": 0
|
||||
* }
|
||||
*/
|
||||
function validate($id, $notrigger=0)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
/**
|
||||
* Delete commercial proposal
|
||||
*
|
||||
* @param int $id Commercial proposal ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger);
|
||||
if ($result == 0) {
|
||||
throw new RestException(500, 'Error nothing done. May be object is already validated');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
|
||||
}
|
||||
if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
|
||||
)
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Commercial Proposal deleted'
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
* @param array $data Array with data to verify
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
{
|
||||
$propal = array();
|
||||
foreach (Proposals::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$propal[$field] = $data[$field];
|
||||
}
|
||||
|
||||
}
|
||||
return $propal;
|
||||
}
|
||||
/**
|
||||
* Validate a commercial proposal
|
||||
*
|
||||
* @param int $id Commercial proposal ID
|
||||
* @param int $notrigger Use {}
|
||||
*
|
||||
* @url POST {id}/validate
|
||||
*
|
||||
* @return array
|
||||
* FIXME An error 403 is returned if the request has an empty body.
|
||||
* Error message: "Forbidden: Content type `text/plain` is not supported."
|
||||
* Workaround: send this in the body
|
||||
* {
|
||||
* "notrigger": 0
|
||||
* }
|
||||
*/
|
||||
function validate($id, $notrigger=0)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->propal->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger);
|
||||
if ($result == 0) {
|
||||
throw new RestException(500, 'Error nothing done. May be object is already validated');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
* @param array $data Array with data to verify
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
{
|
||||
$propal = array();
|
||||
foreach (Proposals::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$propal[$field] = $data[$field];
|
||||
|
||||
}
|
||||
return $propal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->name);
|
||||
unset($object->lastname);
|
||||
unset($object->firstname);
|
||||
unset($object->civility_id);
|
||||
unset($object->address);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1716,7 +1716,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
|
||||
print '<input type="button" class="button" name="cancel" value="' . $langs->trans("Cancel") . '" onclick="javascript:history.go(-1)">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
@@ -389,7 +389,7 @@ class CommandeApi extends DolibarrApi
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function delLine($id, $lineid) {
|
||||
function deleteLine($id, $lineid) {
|
||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
@@ -353,14 +353,16 @@ class Orders extends DolibarrApi
|
||||
* Delete a line to given order
|
||||
*
|
||||
*
|
||||
* @param int $id Id of commande to update
|
||||
* @param int $id Id of order to update
|
||||
* @param int $lineid Id of line to delete
|
||||
*
|
||||
* @url DELETE {id}/lines/{lineid}
|
||||
*
|
||||
* @return int
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
*/
|
||||
function delLine($id, $lineid) {
|
||||
function deleteLine($id, $lineid) {
|
||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
@@ -373,7 +375,8 @@ class Orders extends DolibarrApi
|
||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
|
||||
if ($updateRes > 0) {
|
||||
return $this->get($id);
|
||||
|
||||
@@ -169,15 +169,11 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
const STATUS_VALIDATED = 1;
|
||||
/**
|
||||
* Accepted (supplier orders)
|
||||
*/
|
||||
const STATUS_ACCEPTED = 2;
|
||||
/**
|
||||
* Shipment on process (customer orders)
|
||||
* Shipment on process
|
||||
*/
|
||||
const STATUS_SHIPMENTONPROCESS = 2;
|
||||
/**
|
||||
* Closed (Sent/Received, billed or not)
|
||||
* Closed (Sent, billed or not)
|
||||
*/
|
||||
const STATUS_CLOSED = 3;
|
||||
|
||||
@@ -1559,10 +1555,10 @@ class Commande extends CommonOrder
|
||||
$sql.= ', ca.code as availability_code, ca.label as availability_label';
|
||||
$sql.= ', dr.code as demand_reason_code';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid AND cr.entity IN (' . getEntity('c_payment_term') . ')';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id AND p.entity IN (' . getEntity('c_paiement') . ')';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
|
||||
$sql.= " WHERE c.entity IN (".getEntity('commande').")";
|
||||
if ($id) $sql.= " AND c.rowid=".$id;
|
||||
@@ -3225,7 +3221,7 @@ class Commande extends CommonOrder
|
||||
}
|
||||
$sql.= $clause." c.entity IN (".getEntity('commande').")";
|
||||
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
|
||||
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
||||
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
||||
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
@@ -3310,7 +3306,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
|
||||
if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
|
||||
if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
|
||||
@@ -3320,7 +3316,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
|
||||
if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
|
||||
if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
|
||||
@@ -3330,7 +3326,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
|
||||
@@ -3340,7 +3336,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
|
||||
@@ -3350,7 +3346,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
|
||||
@@ -3360,7 +3356,7 @@ class Commande extends CommonOrder
|
||||
if ($statut==self::STATUS_CANCELED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderCanceledShort').' </span>'.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
|
||||
if ($statut==self::STATUS_DRAFT) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDraftShort').' </span>'.img_picto($langs->trans('StatusOrderDraft'),'statut0');
|
||||
if ($statut==self::STATUS_VALIDATED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderValidatedShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
|
||||
if ($statut==self::STATUS_ACCEPTED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderToBillShort').' </span>'.img_picto($langs->trans('StatusOrderToBill'),'statut4');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessedShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDeliveredShort').' </span>'.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
|
||||
|
||||
@@ -213,7 +213,7 @@ if (empty($reshook))
|
||||
// TODO Move this into mass action include
|
||||
if ($massaction == 'confirm_createbills') {
|
||||
|
||||
$orders = GETPOST('toselect');
|
||||
$orders = GETPOST('toselect','array');
|
||||
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
|
||||
$validate_invoices = GETPOST('valdate_invoices', 'int');
|
||||
|
||||
@@ -224,13 +224,13 @@ if (empty($reshook))
|
||||
|
||||
$db->begin();
|
||||
|
||||
foreach($orders as $id_order) {
|
||||
|
||||
foreach($orders as $id_order)
|
||||
{
|
||||
$cmd = new Commande($db);
|
||||
if($cmd->fetch($id_order) <= 0) continue;
|
||||
if ($cmd->fetch($id_order) <= 0) continue;
|
||||
|
||||
$object = new Facture($db);
|
||||
if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||
else {
|
||||
|
||||
$object->socid = $cmd->socid;
|
||||
@@ -252,12 +252,10 @@ if (empty($reshook))
|
||||
$res = $object->create($user);
|
||||
|
||||
if($res > 0) $nb_bills_created++;
|
||||
|
||||
}
|
||||
|
||||
if($object->id > 0) {
|
||||
|
||||
$db->begin();
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
|
||||
$sql.= "fk_source";
|
||||
$sql.= ", sourcetype";
|
||||
@@ -270,115 +268,113 @@ if (empty($reshook))
|
||||
$sql.= ", '".$object->element."'";
|
||||
$sql.= ")";
|
||||
|
||||
if ($db->query($sql))
|
||||
if (! $db->query($sql))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
if (! $error)
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
|
||||
@@ -391,27 +387,29 @@ if (empty($reshook))
|
||||
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
|
||||
$toselect = array();
|
||||
|
||||
if(!empty($validate_invoices)) {
|
||||
|
||||
if (! $error && $validate_invoices)
|
||||
{
|
||||
$massaction = $action = 'builddoc';
|
||||
foreach($TAllFact as &$object)
|
||||
{
|
||||
$result = $object->validate($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($TAllFact as &$object) {
|
||||
$object->validate($user);
|
||||
$toselect[] = $object->id; // For builddoc action
|
||||
$id = $object->id; // For builddoc action
|
||||
|
||||
// Fac builddoc
|
||||
$donotredirect = 1;
|
||||
$upload_dir = $conf->facture->dir_output;
|
||||
$permissioncreate=$user->rights->facture->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
$objectclass='Facture';
|
||||
$objectlabel='Invoice';
|
||||
$permtoread = $user->rights->facture->lire;
|
||||
$permtodelete = $user->rights->facture->supprimer;
|
||||
$uploaddir = $conf->facture->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
$massaction = $action = 'confirm_createbills';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@@ -149,7 +149,7 @@ dol_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), -1, 'account'
|
||||
$title=$langs->trans("FinancialAccount")." : ".$object->label;
|
||||
$link=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start-1)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start+1)."'>".img_next('', 'class="valignbottom"')."</a>":"");
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
if (!empty($id))
|
||||
@@ -203,7 +203,7 @@ print '</tr>';
|
||||
$var=true;
|
||||
for ($mois = 1 ; $mois < 13 ; $mois++)
|
||||
{
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<td>".dol_print_date(dol_mktime(1,1,1,$mois,1,2000),"%B")."</td>";
|
||||
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/bank/bankentries.php
|
||||
* \file htdocs/compta/bank/bankentries_list.php
|
||||
* \ingroup banque
|
||||
* \brief List of bank transactions
|
||||
*/
|
||||
@@ -405,7 +405,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$head=bank_prepare_head($object);
|
||||
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
|
||||
|
||||
@@ -447,7 +447,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($object->canBeConciliated() > 0) {
|
||||
// If not cash account and can be reconciliate
|
||||
if ($user->rights->banque->consolidate) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
@@ -559,7 +559,7 @@ if (! empty($thirdparty)) $mode_balance_ok=false;
|
||||
|
||||
$sql.= $db->plimit($limit+1,$offset);
|
||||
|
||||
dol_syslog('compta/bank/bankentries.php', LOG_DEBUG);
|
||||
dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -1161,7 +1161,7 @@ if ($resql)
|
||||
if (! empty($arrayfields['type']['checked']))
|
||||
{
|
||||
print '<td align="center" class="nowrap">';
|
||||
$labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle');
|
||||
$labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle','',1);
|
||||
if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance");
|
||||
else print $labeltype;
|
||||
print "</td>\n";
|
||||
@@ -74,9 +74,9 @@ if ($result)
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries.php?bid=$objp->rowid\">$objp->label</a></td>";
|
||||
print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries_list.php?bid=$objp->rowid\">$objp->label</a></td>";
|
||||
print '<td align="right">'.$objp->nombre.'</td>';
|
||||
print '<td align="right">'.price(abs($objp->somme))."</td>";
|
||||
print '<td align="right">'.price(abs(price2num($objp->somme / $objp->nombre,'MT')))."</td>";
|
||||
|
||||
@@ -72,204 +72,204 @@ if ($cancel) $action='';
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
$error=0;
|
||||
$error=0;
|
||||
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
// Create account
|
||||
$object = new Account($db);
|
||||
// Create account
|
||||
$object = new Account($db);
|
||||
|
||||
$object->ref = dol_sanitizeFileName(trim($_POST["ref"]));
|
||||
$object->label = trim($_POST["label"]);
|
||||
$object->courant = $_POST["type"];
|
||||
$object->clos = $_POST["clos"];
|
||||
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
|
||||
$object->url = $_POST["url"];
|
||||
$object->ref = dol_sanitizeFileName(trim($_POST["ref"]));
|
||||
$object->label = trim($_POST["label"]);
|
||||
$object->courant = $_POST["type"];
|
||||
$object->clos = $_POST["clos"];
|
||||
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
|
||||
$object->url = $_POST["url"];
|
||||
|
||||
$object->bank = trim($_POST["bank"]);
|
||||
$object->code_banque = trim($_POST["code_banque"]);
|
||||
$object->code_guichet = trim($_POST["code_guichet"]);
|
||||
$object->number = trim($_POST["number"]);
|
||||
$object->cle_rib = trim($_POST["cle_rib"]);
|
||||
$object->bic = trim($_POST["bic"]);
|
||||
$object->iban = trim($_POST["iban"]);
|
||||
$object->domiciliation = trim($_POST["domiciliation"]);
|
||||
$object->code_banque = trim($_POST["code_banque"]);
|
||||
$object->code_guichet = trim($_POST["code_guichet"]);
|
||||
$object->number = trim($_POST["number"]);
|
||||
$object->cle_rib = trim($_POST["cle_rib"]);
|
||||
$object->bic = trim($_POST["bic"]);
|
||||
$object->iban = trim($_POST["iban"]);
|
||||
$object->domiciliation = trim($_POST["domiciliation"]);
|
||||
|
||||
$object->proprio = trim($_POST["proprio"]);
|
||||
$object->owner_address = trim($_POST["owner_address"]);
|
||||
$object->proprio = trim($_POST["proprio"]);
|
||||
$object->owner_address = trim($_POST["owner_address"]);
|
||||
|
||||
$account_number = GETPOST('account_number','alpha');
|
||||
if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
|
||||
$fk_accountancy_journal = GETPOST('fk_accountancy_journal','int');
|
||||
if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
|
||||
|
||||
$object->solde = $_POST["solde"];
|
||||
$object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||
$object->solde = $_POST["solde"];
|
||||
$object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||
|
||||
$object->currency_code = trim($_POST["account_currency_code"]);
|
||||
$object->currency_code = trim($_POST["account_currency_code"]);
|
||||
|
||||
$object->state_id = $_POST["account_state_id"];
|
||||
$object->country_id = $_POST["account_country_id"];
|
||||
$object->state_id = $_POST["account_state_id"];
|
||||
$object->country_id = $_POST["account_country_id"];
|
||||
|
||||
$object->min_allowed = GETPOST("account_min_allowed",'int');
|
||||
$object->min_desired = GETPOST("account_min_desired",'int');
|
||||
$object->comment = trim(GETPOST("account_comment"));
|
||||
$object->min_allowed = GETPOST("account_min_allowed",'int');
|
||||
$object->min_desired = GETPOST("account_min_desired",'int');
|
||||
$object->comment = trim(GETPOST("account_comment"));
|
||||
|
||||
$object->fk_user_author = $user->id;
|
||||
$object->fk_user_author = $user->id;
|
||||
|
||||
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->ref))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->label))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->ref))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->label))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$id = $object->create($user);
|
||||
if ($id > 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
if (! $error)
|
||||
{
|
||||
$id = $object->create($user);
|
||||
if ($id > 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
|
||||
$_GET["id"]=$id; // Force chargement page en mode visu
|
||||
$_GET["id"]=$id; // Force chargement page en mode visu
|
||||
|
||||
$action='';
|
||||
}
|
||||
else {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
else {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
}
|
||||
}
|
||||
$action='create'; // Force chargement page en mode creation
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
$error=0;
|
||||
$error=0;
|
||||
|
||||
// Update account
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST("id"));
|
||||
// Update account
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST("id"));
|
||||
|
||||
$object->ref = dol_string_nospecial(trim($_POST["ref"]));
|
||||
$object->label = trim($_POST["label"]);
|
||||
$object->courant = $_POST["type"];
|
||||
$object->clos = $_POST["clos"];
|
||||
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
|
||||
$object->url = trim($_POST["url"]);
|
||||
$object->ref = dol_string_nospecial(trim($_POST["ref"]));
|
||||
$object->label = trim($_POST["label"]);
|
||||
$object->courant = $_POST["type"];
|
||||
$object->clos = $_POST["clos"];
|
||||
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
|
||||
$object->url = trim($_POST["url"]);
|
||||
|
||||
$object->bank = trim($_POST["bank"]);
|
||||
$object->code_banque = trim($_POST["code_banque"]);
|
||||
$object->code_guichet = trim($_POST["code_guichet"]);
|
||||
$object->number = trim($_POST["number"]);
|
||||
$object->cle_rib = trim($_POST["cle_rib"]);
|
||||
$object->bic = trim($_POST["bic"]);
|
||||
$object->iban = trim($_POST["iban"]);
|
||||
$object->domiciliation = trim($_POST["domiciliation"]);
|
||||
$object->bank = trim($_POST["bank"]);
|
||||
$object->code_banque = trim($_POST["code_banque"]);
|
||||
$object->code_guichet = trim($_POST["code_guichet"]);
|
||||
$object->number = trim($_POST["number"]);
|
||||
$object->cle_rib = trim($_POST["cle_rib"]);
|
||||
$object->bic = trim($_POST["bic"]);
|
||||
$object->iban = trim($_POST["iban"]);
|
||||
$object->domiciliation = trim($_POST["domiciliation"]);
|
||||
|
||||
$object->proprio = trim($_POST["proprio"]);
|
||||
$object->owner_address = trim($_POST["owner_address"]);
|
||||
$object->proprio = trim($_POST["proprio"]);
|
||||
$object->owner_address = trim($_POST["owner_address"]);
|
||||
|
||||
$account_number = GETPOST('account_number', 'int');
|
||||
if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
|
||||
$fk_accountancy_journal = GETPOST('fk_accountancy_journal','int');
|
||||
if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
|
||||
|
||||
$object->currency_code = trim($_POST["account_currency_code"]);
|
||||
$object->currency_code = trim($_POST["account_currency_code"]);
|
||||
|
||||
$object->state_id = $_POST["account_state_id"];
|
||||
$object->country_id = $_POST["account_country_id"];
|
||||
$object->state_id = $_POST["account_state_id"];
|
||||
$object->country_id = $_POST["account_country_id"];
|
||||
|
||||
$object->min_allowed = GETPOST("account_min_allowed",'int');
|
||||
$object->min_desired = GETPOST("account_min_desired",'int');
|
||||
$object->comment = trim(GETPOST("account_comment"));
|
||||
$object->min_allowed = GETPOST("account_min_allowed",'int');
|
||||
$object->min_desired = GETPOST("account_min_desired",'int');
|
||||
$object->comment = trim(GETPOST("account_comment"));
|
||||
|
||||
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->ref))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->label))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->ref))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->label))
|
||||
{
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
|
||||
$action='edit'; // Force chargement page en mode creation
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result = $object->update($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
if (! $error)
|
||||
{
|
||||
$result = $object->update($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories', 'array');
|
||||
$object->setCategories($categories);
|
||||
|
||||
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='edit'; // Force chargement page edition
|
||||
}
|
||||
}
|
||||
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='edit'; // Force chargement page edition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
|
||||
{
|
||||
// Delete
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST("id","int"));
|
||||
$result = $object->delete($user);
|
||||
// Delete
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST("id","int"));
|
||||
$result = $object->delete($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
header("Location: ".DOL_URL_ROOT."/compta/bank/list.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,10 +297,10 @@ if ($action == 'create')
|
||||
|
||||
print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
print 'jQuery(document).ready(function () {
|
||||
jQuery("#selecttype").change(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.submit();
|
||||
@@ -310,8 +310,8 @@ if ($action == 'create')
|
||||
document.formsoc.submit();
|
||||
});
|
||||
})';
|
||||
print '</script>'."\n";
|
||||
}
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@@ -324,11 +324,11 @@ if ($action == 'create')
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input size="8" type="text" class="flat" name="ref" value="'.(GETPOST("ref")?GETPOST("ref",'alpha'):$object->ref).'" maxlength="12"></td></tr>';
|
||||
print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOST("ref")?GETPOST("ref",'alpha'):$object->ref).'" maxlength="12" autofocus></td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
|
||||
print '<td><input size="30" type="text" class="flat" name="label" value="'.GETPOST("label", 'alpha').'"></td></tr>';
|
||||
print '<td><input size="30" type="text" class="flat" name="label" value="'.dol_escape_htmltag(GETPOST("label", 'alpha')).'"></td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
|
||||
@@ -347,12 +347,12 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td>';
|
||||
print $form->selectarray("clos", $object->status,(isset($_POST["clos"])?$_POST["clos"]:$object->clos));
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td>';
|
||||
print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
|
||||
print '</td></tr>';
|
||||
|
||||
// Country
|
||||
// Country
|
||||
$selectedcode='';
|
||||
if (isset($_POST["account_country_id"]))
|
||||
{
|
||||
@@ -383,24 +383,24 @@ if ($action == 'create')
|
||||
print '<tr><td>'.$langs->trans("Web").'</td>';
|
||||
print '<td><input class="minwidth300" type="text" class="flat" name="url" value="'.GETPOST("url").'"></td></tr>';
|
||||
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Comment
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
|
||||
print '<td>';
|
||||
// Editor wysiwyg
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'90%');
|
||||
$doleditor->Create();
|
||||
@@ -409,7 +409,7 @@ if ($action == 'create')
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit',$parameters);
|
||||
@@ -504,7 +504,7 @@ if ($action == 'create')
|
||||
print '<table class="border" width="100%">';
|
||||
// Accountancy code
|
||||
$fieldrequired='';
|
||||
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
|
||||
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
|
||||
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
@@ -523,7 +523,7 @@ if ($action == 'create')
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||
print '<td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
|
||||
print '</td></tr>';
|
||||
}
|
||||
@@ -547,7 +547,7 @@ if ($action == 'create')
|
||||
/* ************************************************************************** */
|
||||
else
|
||||
{
|
||||
if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
|
||||
if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
|
||||
{
|
||||
$object = new Account($db);
|
||||
if ($_GET["id"])
|
||||
@@ -576,7 +576,7 @@ else
|
||||
// Print form confirm
|
||||
print $formconfirm;
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref='';
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
@@ -605,7 +605,7 @@ else
|
||||
print '<td>';
|
||||
$conciliate=$object->canBeConciliated();
|
||||
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
|
||||
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
|
||||
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
|
||||
else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
|
||||
print '</td></tr>';
|
||||
|
||||
@@ -624,15 +624,15 @@ else
|
||||
|
||||
print $accountingaccount->getNomUrl(0,1,1,'',1);
|
||||
} else {
|
||||
print $object->account_number;
|
||||
print $object->account_number;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy journal
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||
print '<td>';
|
||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||
print '<td>';
|
||||
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$accountingjournal->fetch($object->fk_accountancy_journal);
|
||||
@@ -655,12 +655,12 @@ else
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
|
||||
print $form->showCategories($object->id,'bank_account',1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
// Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
|
||||
print $form->showCategories($object->id,'bank_account',1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
|
||||
print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
|
||||
@@ -669,11 +669,11 @@ else
|
||||
|
||||
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT)
|
||||
{
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
|
||||
print '<td>'.$object->bank.'</td></tr>';
|
||||
@@ -764,23 +764,23 @@ else
|
||||
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
|
||||
{
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST('id','int'));
|
||||
if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
|
||||
{
|
||||
$object = new Account($db);
|
||||
$object->fetch(GETPOST('id','int'));
|
||||
|
||||
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
|
||||
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
jQuery("#selecttype").change(function() {
|
||||
document.formsoc.action.value="edit";
|
||||
document.formsoc.submit();
|
||||
@@ -793,33 +793,33 @@ else
|
||||
document.formsoc.submit();
|
||||
});
|
||||
})';
|
||||
print '</script>'."\n";
|
||||
}
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
|
||||
|
||||
dol_fiche_head('');
|
||||
dol_fiche_head('');
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
|
||||
print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
|
||||
print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
|
||||
print '<td class="maxwidth200onsmartphone">';
|
||||
// Type
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
|
||||
print '<td class="maxwidth200onsmartphone">';
|
||||
$formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type),"type");
|
||||
print '</td></tr>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Currency
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
|
||||
@@ -834,10 +834,10 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="maxwidth200onsmartphone">';
|
||||
print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="maxwidth200onsmartphone">';
|
||||
print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
|
||||
print '</td></tr>';
|
||||
|
||||
// Country
|
||||
$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
|
||||
@@ -865,15 +865,15 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// Conciliable
|
||||
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
|
||||
print '<td>';
|
||||
$conciliate=$object->canBeConciliated();
|
||||
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
|
||||
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
|
||||
else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
|
||||
print '<td>';
|
||||
$conciliate=$object->canBeConciliated();
|
||||
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
|
||||
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
|
||||
else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
|
||||
print '</td></tr>';
|
||||
|
||||
// Balance
|
||||
// Balance
|
||||
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
|
||||
print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"])?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
|
||||
|
||||
@@ -881,28 +881,28 @@ else
|
||||
print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"])?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
|
||||
|
||||
// Web
|
||||
print '<tr><td>'.$langs->trans("Web").'</td>';
|
||||
print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Web").'</td>';
|
||||
print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Comment
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
|
||||
print '<td>';
|
||||
// Editor wysiwyg
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'95%');
|
||||
$doleditor->Create();
|
||||
@@ -911,7 +911,7 @@ else
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
@@ -929,15 +929,15 @@ else
|
||||
$tdextra = ' class="titlefieldcreate"';
|
||||
|
||||
if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
|
||||
$tdextra = ' class="fieldrequired titlefieldcreate"';
|
||||
$tdextra = ' class="fieldrequired titlefieldcreate"';
|
||||
}
|
||||
|
||||
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td>';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
|
||||
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
|
||||
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@@ -954,9 +954,9 @@ else
|
||||
|
||||
if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
|
||||
{
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
//print '<div class="underbanner clearboth"></div>';
|
||||
//print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
@@ -412,8 +412,9 @@ class Account extends CommonObject
|
||||
|
||||
if (is_numeric($oper)) // Clean oper to have a code instead of a rowid
|
||||
{
|
||||
$sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
|
||||
$sql.=" WHERE id=".$oper;
|
||||
$sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
|
||||
$sql.= " WHERE id=".$oper;
|
||||
$sql.= " AND entity IN (" . getEntity('c_paiement') . ")";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -1161,50 +1162,88 @@ class Account extends CommonObject
|
||||
*/
|
||||
function load_board(User $user, $filteraccountid = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT b.rowid, b.datev as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.rappro=0";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
$sql = "SELECT b.rowid, b.datev as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.rappro=0";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$langs->load("banks");
|
||||
$now=dol_now();
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$langs->load("banks");
|
||||
$now=dol_now();
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
|
||||
$response->label=$langs->trans("TransactionsToConciliate");
|
||||
$response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
|
||||
$response->img=img_object('',"payment");
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
|
||||
$response->label=$langs->trans("TransactionsToConciliate");
|
||||
$response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank';
|
||||
$response->img=img_object('',"payment");
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb de tableau de bord
|
||||
* @param int $filteraccountid To get info for a particular account id
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function load_state_board($filteraccountid = 0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT count(b.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nb["banklines"]=$obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1241,14 +1280,15 @@ class Account extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto Include picto into link
|
||||
* @param string $mode ''=Link to card, 'transactions'=Link to transactions card
|
||||
* @param string $option ''=Show ref, 'reflabel'=Show ref+label
|
||||
* @return string Chaine avec URL
|
||||
* @param int $withpicto Include picto into link
|
||||
* @param string $mode ''=Link to card, 'transactions'=Link to transactions card
|
||||
* @param string $option ''=Show ref, 'reflabel'=Show ref+label
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $mode='', $option='')
|
||||
function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@@ -1266,22 +1306,27 @@ class Account extends CommonObject
|
||||
}
|
||||
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
|
||||
if (empty($mode))
|
||||
$url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id;
|
||||
if ($mode == 'transactions')
|
||||
{
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id.$linkclose;
|
||||
$linkend='</a>';
|
||||
}
|
||||
else if ($mode == 'transactions')
|
||||
{
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$this->id.$linkclose;
|
||||
$linkend='</a>';
|
||||
$url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id;
|
||||
}
|
||||
else if ($mode == 'receipts')
|
||||
{
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id.$linkclose;
|
||||
$linkend='</a>';
|
||||
$url = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id;
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
$link = '<a href="'.$url.$linkclose;
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' ');
|
||||
$result.=$link.$this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '').$linkend;
|
||||
return $result;
|
||||
|
||||
@@ -117,7 +117,7 @@ if ($id > 0 || !empty($ref)) {
|
||||
$totalsize+=$file['size'];
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
if (empty($min)) $min = dol_now - 3600 * 24;
|
||||
|
||||
|
||||
$log="graph.php: min=".$min." max=".$max;
|
||||
dol_syslog($log);
|
||||
|
||||
@@ -760,7 +760,7 @@ $head=bank_prepare_head($object);
|
||||
dol_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0,'account');
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
if ($account)
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ $h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("LineRecord"), -1, 'account');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback);
|
||||
|
||||
@@ -152,7 +152,7 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$arrayofcategs=GETPOST('custcats', 'array');
|
||||
@@ -175,8 +175,8 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
}
|
||||
// $arrayselected will be loaded after in page output
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||
@@ -296,14 +296,14 @@ if ($result)
|
||||
print '<input type="hidden" name="id" value="'.$acct->id.'">';
|
||||
|
||||
dol_fiche_head($tabs, 0, $langs->trans('LineRecord'), 0, 'account');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
dol_banner_tab($bankline, 'rowid', $linkback);
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
@@ -314,7 +314,7 @@ if ($result)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
|
||||
$i++;
|
||||
|
||||
// Bank account
|
||||
@@ -582,7 +582,7 @@ if ($result)
|
||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||
{
|
||||
$langs->load('categories');
|
||||
|
||||
|
||||
// Bank line
|
||||
print '<tr><td class="toptd">' . fieldLabel('RubriquesTransactions', 'custcats') . '</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
|
||||
@@ -591,28 +591,28 @@ if ($result)
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
|
||||
|
||||
|
||||
print "</form>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Releve rappro
|
||||
if ($acct->canBeConciliated() > 0) // Si compte rapprochable
|
||||
{
|
||||
print load_fiche_titre($langs->trans("Reconciliation"), '', 'title_bank.png');
|
||||
print '<hr>'."\n";
|
||||
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="setreconcile">';
|
||||
print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Conciliation")."</td>";
|
||||
@@ -652,13 +652,13 @@ if ($result)
|
||||
print '</table>';
|
||||
|
||||
print '<div class="center">';
|
||||
|
||||
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Update").'">';
|
||||
if ($backtopage)
|
||||
{
|
||||
print ' ';
|
||||
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/bank/index.php
|
||||
* \file htdocs/compta/bank/list.php
|
||||
* \ingroup banque
|
||||
* \brief Home page of bank module
|
||||
*/
|
||||
@@ -611,7 +611,7 @@ foreach ($accounts as $key=>$type)
|
||||
if (! empty($arrayfields['balance']['checked']))
|
||||
{
|
||||
print '<td align="right">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$obj->id.'">'.price($solde, 0, $langs, 0, 0, -1, $obj->currency_code).'</a>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$obj->id.'">'.price($solde, 0, $langs, 0, 0, -1, $obj->currency_code).'</a>';
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
|
||||
@@ -328,7 +328,7 @@ if (empty($numref))
|
||||
$head=bank_prepare_head($object);
|
||||
dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
|
||||
|
||||
@@ -340,7 +340,7 @@ if (empty($numref))
|
||||
if ($object->canBeConciliated() > 0) {
|
||||
// If not cash account and can be reconciliate
|
||||
if ($user->rights->banque->consolidate) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
$head=bank_prepare_head($object);
|
||||
dol_fiche_head($head, 'cash', $langs->trans("FinancialAccount"), -1, 'account');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
$solde = $object->solde(0);
|
||||
|
||||
// Show next coming entries
|
||||
@@ -120,13 +120,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
$var=true;
|
||||
|
||||
// Current balance
|
||||
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="left" colspan="5">'.$langs->trans("CurrentBalance").'</td>';
|
||||
print '<td align="right" class="nowrap">'.price($solde).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left" colspan="5">'.$langs->trans("RemainderToPay").'</td>';
|
||||
print '<td align="right" class="nowrap"> </td>';
|
||||
@@ -295,7 +295,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
// We discard lines with a remainder to pay to 0
|
||||
if (price2num($total_ttc) != 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Show line
|
||||
print '<tr class="oddeven">';
|
||||
@@ -320,7 +320,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
}
|
||||
|
||||
// Solde actuel
|
||||
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="left" colspan="5">'.$langs->trans("FutureBalance").' ('.$object->currency_code.')</td>';
|
||||
print '<td align="right" class="nowrap">'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).'</td>';
|
||||
|
||||
@@ -96,7 +96,7 @@ $sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v
|
||||
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
|
||||
$sql.= " pst.code as payment_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement');
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE v.entity = ".$conf->entity;
|
||||
|
||||
@@ -139,7 +139,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement');
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE cs.fk_type = c.id";
|
||||
@@ -260,7 +260,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE pv.entity = ".$conf->entity;
|
||||
if ($year > 0)
|
||||
{
|
||||
@@ -474,7 +474,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity = " . getEntity('c_paiement');
|
||||
$sql.= " , ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('user').")";
|
||||
$sql.= " AND u.rowid = s.fk_user";
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
|
||||
@@ -716,9 +717,13 @@ if (empty($reshook))
|
||||
if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION)
|
||||
{
|
||||
// If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT
|
||||
$sql = 'SELECT SUM(pf.amount) as total_paiements
|
||||
FROM llx_c_paiement as c, llx_paiement_facture as pf, llx_paiement as p
|
||||
WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
|
||||
|
||||
$sql = 'SELECT SUM(pf.amount) as total_paiements';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
|
||||
$sql.= ' WHERE pf.fk_facture = '.$object->id;
|
||||
$sql.= ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
|
||||
$sql.= ' AND c.entity IN (' . getEntity('c_paiement').')';
|
||||
$sql.= ' ORDER BY p.datep, p.tms';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
@@ -3798,6 +3803,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
|
||||
$sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
|
||||
$sql .= ' AND c.entity IN (' . getEntity('c_paiement').')';
|
||||
$sql .= ' ORDER BY p.datep, p.tms';
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -3810,18 +3816,21 @@ else if ($id > 0 || ! empty($ref))
|
||||
if ($num > 0) {
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
print '<tr class="oddeven"><td>';
|
||||
|
||||
$paymentstatic->id = $objp->rowid;
|
||||
$paymentstatic->datepaye = $db->jdate($objp->dp);
|
||||
$paymentstatic->ref = $objp->ref;
|
||||
$paymentstatic->num_paiement = $objp->num_paiement;
|
||||
$paymentstatic->payment_code = $objp->payment_code;
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $paymentstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td>' . dol_print_date($db->jdate($objp->dp), 'day') . '</td>';
|
||||
$label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label;
|
||||
print '<td>' . $label . ' ' . $objp->num_paiement . '</td>';
|
||||
if (! empty($conf->banque->enabled)) {
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
$bankaccountstatic->id = $objp->baid;
|
||||
$bankaccountstatic->ref = $objp->baref;
|
||||
$bankaccountstatic->label = $objp->baref;
|
||||
@@ -4324,7 +4333,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Delete
|
||||
if ($user->rights->facture->supprimer)
|
||||
{
|
||||
if (! $object->is_erasable()) {
|
||||
if ($object->is_erasable() <= 0) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecauseNotErasable") . '">' . $langs->trans('Delete') . '</a></div>';
|
||||
} else if ($objectidnext) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('Delete') . '</a></div>';
|
||||
|
||||
@@ -305,16 +305,66 @@ class Invoices extends DolibarrApi
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a line of a given invoice
|
||||
*
|
||||
* @param int $id Id of invoice
|
||||
* @param int $lineid Id of the line to delete
|
||||
*
|
||||
* @url DELETE {id}/lines/{lineid}
|
||||
*
|
||||
* @return array
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
* @throws 405
|
||||
*/
|
||||
function deleteLine($id, $lineid) {
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->facture->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($lineid)) {
|
||||
throw new RestException(400, 'Line ID is mandatory');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
$result = $this->invoice->deleteline($lineid);
|
||||
if( $result < 0) {
|
||||
throw new RestException(405, $this->invoice->error);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
|
||||
$this->invoice->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->invoice->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a line to a given invoice
|
||||
*
|
||||
* Exemple of POST query : { "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null }
|
||||
*
|
||||
* Exemple of POST query : { "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null }
|
||||
*
|
||||
* @param int $id Id of invoice
|
||||
* @param array $request_data Invoiceline data
|
||||
*
|
||||
* @url POST {id}/lines
|
||||
* @url POST {id}/addline
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -331,14 +381,14 @@ class Invoices extends DolibarrApi
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$request_data = (object) $request_data;
|
||||
|
||||
|
||||
$request_data = (object) $request_data;
|
||||
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
|
||||
$request_data->fk_parent_line = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$updateRes = $this->invoice->addline(
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
@@ -378,7 +428,59 @@ class Invoices extends DolibarrApi
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an order
|
||||
* Sets an invoice as draft
|
||||
*
|
||||
* @param int $id Order ID
|
||||
* @param int $idwarehouse Warehouse ID
|
||||
*
|
||||
* @url POST {id}/settodraft
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws 200
|
||||
* @throws 304
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
* @throws 500
|
||||
*
|
||||
*/
|
||||
function settodraft($id, $idwarehouse=-1)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->invoice->set_draft(DolibarrApiAccess::$user, $idwarehouse);
|
||||
if ($result == 0) {
|
||||
throw new RestException(304, 'Nothing done.');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error : '.$this->invoice->error);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate an invoice
|
||||
*
|
||||
* @param int $id Order ID
|
||||
* @param int $idwarehouse Warehouse ID
|
||||
@@ -411,20 +513,82 @@ class Invoices extends DolibarrApi
|
||||
|
||||
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
|
||||
if ($result == 0) {
|
||||
throw new RestException(500, 'Error nothing done. May be object is already validated');
|
||||
throw new RestException(304, 'Error nothing done. May be object is already validated');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an invoice as paid
|
||||
*
|
||||
* @param int $id Order ID
|
||||
* @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple)
|
||||
* @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple)
|
||||
*
|
||||
* @url POST {id}/settopaid
|
||||
*
|
||||
* @return array An invoice object
|
||||
*
|
||||
* @throws 200
|
||||
* @throws 304
|
||||
* @throws 401
|
||||
* @throws 404
|
||||
* @throws 500
|
||||
*/
|
||||
function settopaid($id, $close_code='', $close_note='')
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->facture->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note);
|
||||
if ($result == 0) {
|
||||
throw new RestException(304, 'Error nothing done. May be object is already validated');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error : '.$this->invoice->error);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
|
||||
@@ -262,8 +262,8 @@ class FactureRec extends CommonInvoice
|
||||
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
|
||||
//$sql.= ', el.fk_source';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN (' . getEntity('c_payment_term').')';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN (' . getEntity('c_paiement').')';
|
||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'";
|
||||
if ($rowid) $sql.= ' WHERE f.rowid='.$rowid;
|
||||
elseif ($ref) $sql.= " WHERE f.titre='".$this->db->escape($ref)."'";
|
||||
|
||||
@@ -1076,18 +1076,19 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
* @param int $withpicto Add picto into link
|
||||
* @param string $option Where point the link
|
||||
* @param int $max Maxlength of ref
|
||||
* @param int $short 1=Return just URL
|
||||
* @param string $moretitle Add more text to title tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $addlinktonotes 1=Add link to notes
|
||||
* @return string String with URL
|
||||
* @param int $withpicto Add picto into link
|
||||
* @param string $option Where point the link
|
||||
* @param int $max Maxlength of ref
|
||||
* @param int $short 1=Return just URL
|
||||
* @param string $moretitle Add more text to title tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $addlinktonotes 1=Add link to notes
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='',$notooltip=0,$addlinktonotes=0)
|
||||
function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $moretitle='', $notooltip=0, $addlinktonotes=0, $save_lastsearch_value=-1)
|
||||
{
|
||||
global $langs, $conf, $user, $form;
|
||||
|
||||
@@ -1100,6 +1101,14 @@ class Facture extends CommonInvoice
|
||||
|
||||
if ($short) return $url;
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
$picto='bill';
|
||||
if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice
|
||||
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
|
||||
@@ -1197,8 +1206,8 @@ class Facture extends CommonInvoice
|
||||
$sql.= ', f.fk_incoterms, f.location_incoterms';
|
||||
$sql.= ", i.libelle as libelle_incoterms";
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN (' . getEntity('c_payment_term').')';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN (' . getEntity('c_paiement').')';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
|
||||
$sql.= ' WHERE f.entity = '.$conf->entity;
|
||||
if ($rowid) $sql.= " AND f.rowid=".$rowid;
|
||||
@@ -1744,9 +1753,9 @@ class Facture extends CommonInvoice
|
||||
global $langs,$conf;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
$rowid=$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG);
|
||||
|
||||
// Test to avoid invoice deletion (allowed if draft)
|
||||
$test = $this->is_erasable();
|
||||
@@ -2076,7 +2085,7 @@ class Facture extends CommonInvoice
|
||||
* @param string $force_number Reference to force on invoice
|
||||
* @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK
|
||||
*/
|
||||
function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
|
||||
{
|
||||
@@ -2088,6 +2097,10 @@ class Facture extends CommonInvoice
|
||||
$error=0;
|
||||
dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse);
|
||||
|
||||
// Force to have object complete for checks
|
||||
$this->fetch_thirdparty();
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if (! $this->brouillon)
|
||||
{
|
||||
@@ -2110,9 +2123,6 @@ class Facture extends CommonInvoice
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->fetch_thirdparty();
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement
|
||||
{
|
||||
@@ -3171,6 +3181,7 @@ class Facture extends CommonInvoice
|
||||
//$sql.= ' WHERE pf.'.$field.' = 1';
|
||||
$sql.= ' AND pf.'.$field2.' = p.rowid';
|
||||
$sql.= ' AND p.fk_paiement = t.id';
|
||||
$sql.= ' AND t.entity IN (' . getEntity('c_paiement').')';
|
||||
if ($filtertype) $sql.=" AND t.code='PRE'";
|
||||
|
||||
dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
|
||||
@@ -3217,6 +3228,8 @@ class Facture extends CommonInvoice
|
||||
|
||||
if (! empty($conf->global->FACTURE_ADDON))
|
||||
{
|
||||
dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG);
|
||||
|
||||
$mybool=false;
|
||||
|
||||
$file = $conf->global->FACTURE_ADDON.".php";
|
||||
@@ -3364,36 +3377,39 @@ class Facture extends CommonInvoice
|
||||
* If hidden option INVOICE_CAN_ALWAYS_BE_REMOVED is on, we can. If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on, we can't.
|
||||
* If invoice has a definitive ref, is last, without payment and not dipatched into accountancy -> yes end of rule
|
||||
*
|
||||
* @return int <0 if KO, 0=no, 1=yes
|
||||
* @return int <0 if KO, 0=no, >0=yes
|
||||
*/
|
||||
function is_erasable()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// on verifie si la facture est en numerotation provisoire
|
||||
$facref = substr($this->ref, 1, 4);
|
||||
// we check if invoice is a temporary number (PROVxxxx)
|
||||
$tmppart = substr($this->ref, 1, 4);
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // If draft invoice and ref not yet defined
|
||||
if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) return 1;
|
||||
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) return 2;
|
||||
if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
|
||||
|
||||
// TODO Test if there is at least one payment. If yes, refuse to delete.
|
||||
// ...
|
||||
|
||||
// If not a draft invoice and not temporary invoice
|
||||
if ($facref != 'PROV')
|
||||
if ($tmppart !== 'PROV')
|
||||
{
|
||||
// We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
|
||||
if (empty($this->thirdparty)) $this->fetch_thirdparty();
|
||||
|
||||
$maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
|
||||
$ventilExportCompta = $this->getVentilExportCompta();
|
||||
|
||||
// If there is no invoice into the reset range and not already dispatched, we can delete
|
||||
if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1;
|
||||
if ($maxfacnumber == '' && $ventilExportCompta == 0) return 3;
|
||||
// If invoice to delete is last one and not already dispatched, we can delete
|
||||
if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 1;
|
||||
if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 4;
|
||||
|
||||
if ($this->situation_cycle_ref) {
|
||||
$last = $this->is_last_in_cycle();
|
||||
@@ -3659,7 +3675,7 @@ class Facture extends CommonInvoice
|
||||
if (! $error)
|
||||
{
|
||||
// Force payment mode of invoice to withdraw
|
||||
$payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement');
|
||||
$payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1);
|
||||
if ($payment_mode_id > 0)
|
||||
{
|
||||
$result=$this->setPaymentMethods($payment_mode_id);
|
||||
|
||||
@@ -91,6 +91,7 @@ class PaymentTerm // extends CommonObject
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_payment_term(";
|
||||
$sql.= "rowid,";
|
||||
$sql.= "entity,";
|
||||
$sql.= "code,";
|
||||
$sql.= "sortorder,";
|
||||
$sql.= "active,";
|
||||
@@ -101,6 +102,7 @@ class PaymentTerm // extends CommonObject
|
||||
$sql.= "decalage";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
|
||||
$sql.= " ".(! isset($this->entity)?getEntity('c_payment_term'):"'".$this->db->escape($this->entity)."'").",";
|
||||
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
|
||||
$sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->db->escape($this->sortorder)."'").",";
|
||||
$sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").",";
|
||||
@@ -165,6 +167,7 @@ class PaymentTerm // extends CommonObject
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.entity";
|
||||
|
||||
$sql.= " t.code,";
|
||||
$sql.= " t.sortorder,";
|
||||
@@ -178,6 +181,7 @@ class PaymentTerm // extends CommonObject
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
|
||||
$sql.= " WHERE t.rowid = ".$id;
|
||||
$sql.= " AND t.entity = " . getEntity('c_payment_term');
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@@ -227,6 +231,7 @@ class PaymentTerm // extends CommonObject
|
||||
$sql.= " t.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
|
||||
$sql.= " WHERE t.code = 'RECEP'";
|
||||
$sql.= " AND t.entity = " . getEntity('c_payment_term');
|
||||
|
||||
dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@@ -255,9 +260,10 @@ class PaymentTerm // extends CommonObject
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user=null, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
function update($user=null, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
@@ -276,8 +282,8 @@ class PaymentTerm // extends CommonObject
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."c_payment_term SET";
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."c_payment_term SET";
|
||||
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
|
||||
$sql.= " sortorder=".(isset($this->sortorder)?$this->sortorder:"null").",";
|
||||
$sql.= " active=".(isset($this->active)?$this->active:"null").",";
|
||||
@@ -286,37 +292,38 @@ class PaymentTerm // extends CommonObject
|
||||
$sql.= " type_cdr=".(isset($this->type_cdr)?$this->type_cdr:"null").",";
|
||||
$sql.= " nbjour=".(isset($this->nbjour)?$this->nbjour:"null").",";
|
||||
$sql.= " decalage=".(isset($this->decalage)?$this->decalage:"null")."";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$sql.= " WHERE rowid = " . $this->id;
|
||||
$sql.= " AND entity = " . getEntity('c_payment_term');
|
||||
|
||||
$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(); }
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action call a trigger.
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action call a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
// 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;
|
||||
@@ -326,7 +333,7 @@ class PaymentTerm // extends CommonObject
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -342,7 +349,8 @@ class PaymentTerm // extends CommonObject
|
||||
$error=0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_payment_term";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$sql.= " WHERE rowid = " . $this->id;
|
||||
$sql.= " AND t.entity = " . getEntity('c_payment_term');
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@@ -139,13 +139,13 @@ if ($id > 0 || ! empty($ref))
|
||||
$head = facture_prepare_head($object);
|
||||
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
|
||||
|
||||
dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill');
|
||||
|
||||
// Invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
@@ -186,11 +186,11 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref, '', 0, '', '', 1);
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<br>';
|
||||
|
||||
@@ -113,7 +113,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
|
||||
@@ -1169,7 +1169,7 @@ else
|
||||
|
||||
// Recurring invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/invoicetemplate_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='';
|
||||
if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
|
||||
|
||||
@@ -58,7 +58,7 @@ $totalpaye = $object->getSommePaiement();
|
||||
|
||||
// Invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
|
||||
@@ -74,14 +74,14 @@ if ($id > 0 || ! empty($ref))
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = facture_prepare_head($object);
|
||||
|
||||
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
|
||||
|
||||
dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
|
||||
|
||||
// Invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
@@ -130,8 +130,8 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
|
||||
|
||||
$cssclass="titlefield";
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ if ($object->id > 0)
|
||||
|
||||
// Invoice content
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref customer
|
||||
@@ -425,28 +425,28 @@ if ($object->id > 0)
|
||||
print '<tr><td>'.$langs->trans("RIB").'</td><td colspan="3">';
|
||||
print $object->thirdparty->display_rib();
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
@@ -507,16 +507,16 @@ if ($object->id > 0)
|
||||
|
||||
// TODO Replace this by an include with same code to show already done payment visible in invoice card
|
||||
print '<tr><td>'.$langs->trans('RemainderToPay').'</td><td class="nowrap">'.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
@@ -612,7 +612,7 @@ if ($object->id > 0)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result_sql);
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n";
|
||||
@@ -640,7 +640,7 @@ if ($object->id > 0)
|
||||
}
|
||||
|
||||
// Closed requests
|
||||
|
||||
|
||||
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande,";
|
||||
$sql.= " pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
|
||||
$sql.= " pb.ref,";
|
||||
@@ -663,7 +663,7 @@ if ($object->id > 0)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ if ($mode == 'customer')
|
||||
if ($mode == 'supplier')
|
||||
{
|
||||
$title=$langs->trans("BillsStatisticsSuppliers");
|
||||
$dir=$conf->fournisseur->dir_output.'/facture/temp';
|
||||
$dir=$conf->fournisseur->facture->dir_temp;
|
||||
}
|
||||
|
||||
print load_fiche_titre($title, $mesg, 'title_accountancy.png');
|
||||
|
||||
@@ -251,7 +251,7 @@ if (empty($reshook))
|
||||
$paiement->datepaye = $datepaye;
|
||||
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
|
||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||
$paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement');
|
||||
$paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',1);
|
||||
$paiement->num_paiement = GETPOST('num_paiement');
|
||||
$paiement->note = GETPOST('comment');
|
||||
|
||||
@@ -526,21 +526,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
* List of unpaid invoices
|
||||
*/
|
||||
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, ';
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, 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';
|
||||
|
||||
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.= ' WHERE f.entity = '.$conf->entity;
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('facture', $conf->entity).')';
|
||||
$sql.= ' AND (f.fk_soc = '.$facture->socid;
|
||||
|
||||
// Can pay invoices of all child of parent company
|
||||
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.')';
|
||||
}
|
||||
|
||||
// Can pay invoices of all child of myself
|
||||
if(!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)){
|
||||
$sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->id.')';
|
||||
}
|
||||
$sql.= ') AND f.paye = 0';
|
||||
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
|
||||
if ($facture->type != 2)
|
||||
@@ -831,7 +829,8 @@ if (! GETPOST('action','aZ09'))
|
||||
$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 = '.$conf->entity;
|
||||
$sql.= ' AND f.entity IN (' . getEntity('facture').')';
|
||||
$sql.= ' AND c.entity IN (' . getEntity('c_paiement').')';
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= ' AND f.fk_soc = '.$socid;
|
||||
|
||||
@@ -71,7 +71,8 @@ if ($socid)
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
|
||||
}
|
||||
$sql.= " WHERE p.fk_paiement = c.id";
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
$sql.= " AND p.entity = " . $conf->entity;
|
||||
$sql.= " AND c.entity = " . getEntity('c_paiement');
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
|
||||
@@ -36,7 +36,7 @@ class RemiseCheque extends CommonObject
|
||||
public $element='chequereceipt';
|
||||
public $table_element='bordereau_cheque';
|
||||
public $picto = 'payment';
|
||||
|
||||
|
||||
var $num;
|
||||
var $intitule;
|
||||
//! Numero d'erreur Plage 1024-1279
|
||||
@@ -345,7 +345,7 @@ class RemiseCheque extends CommonObject
|
||||
$this->errno = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$numref = $this->getNextNumRef();
|
||||
|
||||
if ($this->errno == 0 && $numref)
|
||||
@@ -481,10 +481,10 @@ class RemiseCheque extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user)
|
||||
{
|
||||
@@ -533,6 +533,45 @@ class RemiseCheque extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb de tableau de bord
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function load_state_board()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT count(b.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND b.fk_type = 'CHQ'";
|
||||
$sql.= " AND b.amount > 0";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nb["cheques"]=$obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build document
|
||||
*
|
||||
@@ -716,7 +755,7 @@ class RemiseCheque extends CommonObject
|
||||
*
|
||||
* @param int $bank_id Id of bank transaction line concerned
|
||||
* @param date $rejection_date Date to use on the negative payment
|
||||
* @return int Id of negative payment line created
|
||||
* @return int Id of negative payment line created
|
||||
*/
|
||||
function rejectCheck($bank_id, $rejection_date)
|
||||
{
|
||||
@@ -727,19 +766,19 @@ class RemiseCheque extends CommonObject
|
||||
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($bank_id);
|
||||
|
||||
|
||||
/* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log.
|
||||
if ($bankline->rappro)
|
||||
{
|
||||
$this->error='ActionRefusedLineAlreadyConciliated';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
// Not conciliated, we can delete it
|
||||
//$bankline->delete($user); // We delete
|
||||
|
||||
//$bankline->delete($user); // We delete
|
||||
|
||||
$bankaccount = $payment->fk_account;
|
||||
|
||||
// Get invoices list to reopen them
|
||||
@@ -753,7 +792,7 @@ class RemiseCheque extends CommonObject
|
||||
$rejectedPayment = new Paiement($db);
|
||||
$rejectedPayment->amounts = array();
|
||||
$rejectedPayment->datepaye = $rejection_date;
|
||||
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement');
|
||||
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement','code','id',1);
|
||||
$rejectedPayment->num_paiement = $payment->numero;
|
||||
|
||||
while($obj = $db->fetch_object($resql))
|
||||
|
||||
@@ -203,7 +203,7 @@ if ($resql)
|
||||
|
||||
// Bank
|
||||
print '<td>';
|
||||
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
|
||||
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ class Paiement extends CommonObject
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
|
||||
$sql.= ' WHERE p.fk_paiement = c.id';
|
||||
$sql.= ' AND c.entity IN (' . getEntity('c_paiement').')';
|
||||
if ($id > 0)
|
||||
$sql.= ' AND p.rowid = '.$id;
|
||||
else if ($ref)
|
||||
|
||||
@@ -119,7 +119,8 @@ if (GETPOST("orphelins"))
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_paiement as c)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " WHERE p.fk_paiement = c.id";
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
$sql.= " AND p.entity = " . $conf->entity;
|
||||
$sql.= " AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " AND pf.fk_facture IS NULL";
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
@@ -150,7 +151,8 @@ else
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
}
|
||||
$sql.= " WHERE p.fk_paiement = c.id";
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
$sql.= " AND p.entity = " . $conf->entity;
|
||||
$sql.= " AND c.entity = " . getEntity('c_paiement');
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql.= " AND sc.fk_user = " .$user->id;
|
||||
|
||||
@@ -60,18 +60,21 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
|
||||
if (! $_POST["paiementtype"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")), null, 'errors');
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
if ($datepaye == '')
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")), null, 'errors');
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")), null, 'errors');
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@@ -91,7 +94,8 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
if (count($amounts) <= 0)
|
||||
{
|
||||
$error++;
|
||||
$errmsg='ErrorNoPaymentDefined';
|
||||
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@@ -112,18 +116,20 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
$paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0));
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$errmsg=$paiement->error;
|
||||
$error++;
|
||||
$error++;
|
||||
setEventMessages($paiement->error, null, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)',$_POST['accountid'],'','');
|
||||
if (! $result > 0)
|
||||
$result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)', GETPOST('accountid','int'),'','');
|
||||
if (! ($result > 0))
|
||||
{
|
||||
$errmsg=$paiement->error;
|
||||
$error++;
|
||||
$error++;
|
||||
setEventMessages($paiement->error, null, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +147,6 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes
|
||||
}
|
||||
}
|
||||
|
||||
$_GET["action"]='create';
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +271,7 @@ if ($action == 'create')
|
||||
{
|
||||
$objp = $charge;
|
||||
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ if ($user->societe_id) $socid=$user->societe_id;
|
||||
// TODO ajouter regle pour restreindre acces paiement
|
||||
//$result = restrictedArea($user, 'facture', $id,'');
|
||||
|
||||
$paiement = new PaymentSocialContribution($db);
|
||||
if ($id > 0)
|
||||
$object = new PaymentSocialContribution($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
$result=$paiement->fetch($id);
|
||||
$result=$object->fetch($id);
|
||||
if (! $result) dol_print_error($db,'Failed to get payment id '.$id);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $paiement->delete($user);
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
@@ -70,7 +70,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
@@ -80,8 +80,8 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->char
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=$paiement->valide();
|
||||
|
||||
$result=$object->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
@@ -103,12 +103,12 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->char
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$paiement->id);
|
||||
header('Location: card.php?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
@@ -137,15 +137,15 @@ $h++;
|
||||
*/
|
||||
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), 0, 'payment');
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment');
|
||||
|
||||
/*
|
||||
* Deletion confirmation of payment
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm('card.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
|
||||
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -154,41 +154,49 @@ if ($action == 'delete')
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/payments.php">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
|
||||
/*print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($paiement,'id','',1,'rowid','id');
|
||||
print '</td></tr>';
|
||||
print $form->showrefnav($object,'id','',1,'rowid','id');
|
||||
print '</td></tr>';*/
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($paiement->datep,'day').'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($object->datep,'day').'</td></tr>';
|
||||
|
||||
// Mode
|
||||
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$paiement->type_code).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
|
||||
|
||||
// Numero
|
||||
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->num_paiement.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
|
||||
|
||||
// Montant
|
||||
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($object->note).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
if ($paiement->bank_account)
|
||||
if ($object->bank_account)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($paiement->bank_line);
|
||||
$bankline->fetch($object->bank_line);
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
@@ -201,6 +209,10 @@ if (! empty($conf->banque->enabled))
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
* List of social contributions payed
|
||||
@@ -211,7 +223,7 @@ $sql = 'SELECT f.rowid as scid, f.libelle, f.paye, f.amount as sc_amount, pf.amo
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc';
|
||||
$sql.= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id';
|
||||
$sql.= ' AND f.entity = '.$conf->entity;
|
||||
$sql.= ' AND pf.rowid = '.$paiement->id;
|
||||
$sql.= ' AND pf.rowid = '.$object->id;
|
||||
|
||||
dol_syslog("compta/payment_sc/card.php", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
@@ -239,7 +251,7 @@ if ($resql)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
// Ref
|
||||
print '<td>';
|
||||
@@ -268,7 +280,7 @@ if ($resql)
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
$db->free($resql);
|
||||
@@ -278,7 +290,6 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
@@ -289,7 +300,7 @@ print '<div class="tabsAction">';
|
||||
/*
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
if ($user->societe_id == 0 && $object->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
@@ -299,7 +310,7 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
}
|
||||
*/
|
||||
|
||||
if ($_GET['action'] == '')
|
||||
if ($action == '')
|
||||
{
|
||||
if ($user->rights->tax->charges->supprimer)
|
||||
{
|
||||
|
||||
@@ -822,7 +822,7 @@ else
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
@@ -906,7 +906,7 @@ else
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE p.entity = ".getEntity('donation');
|
||||
$sql.= " AND fk_statut >= 2";
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES'
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||
$sql.= " AND p.fk_statut>=5";
|
||||
|
||||
@@ -761,7 +761,7 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE p.entity = ".getEntity('donation');
|
||||
$sql.= " AND fk_statut >= 2";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
|
||||
@@ -214,6 +214,12 @@ if ($action == 'create')
|
||||
$pastmonthyear--;
|
||||
}
|
||||
|
||||
$datespmonth = GETPOST('datespmonth', 'int');
|
||||
$datespday = GETPOST('datespday', 'int');
|
||||
$datespyear = GETPOST('datespyear', 'int');
|
||||
$dateepmonth = GETPOST('dateepmonth', 'int');
|
||||
$dateepday = GETPOST('dateepday', 'int');
|
||||
$dateepyear = GETPOST('dateepyear', 'int');
|
||||
$datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
|
||||
$dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
|
||||
|
||||
@@ -253,7 +259,7 @@ if ($action == 'create')
|
||||
// Label
|
||||
print '<tr><td>';
|
||||
print fieldLabel('Label','label',1).'</td><td>';
|
||||
print '<input name="label" id="label" class="minwidth300" value="'.($_POST["label"]?GETPOST("label",'',2):$langs->trans("SalaryPayment")).'">';
|
||||
print '<input name="label" id="label" class="minwidth300" value="'.(GETPOST("label")?GETPOST("label"):$langs->trans("SalaryPayment")).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Date start period
|
||||
|
||||
@@ -105,7 +105,7 @@ $sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.da
|
||||
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,";
|
||||
$sql.= " pst.code as payment_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement');
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
@@ -33,6 +34,9 @@ if (! empty($conf->projet->enabled))
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
if (! empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
}
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
@@ -63,50 +67,50 @@ if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm
|
||||
}
|
||||
|
||||
if ($action == 'reopen' && $user->rights->tax->charges->creer) {
|
||||
$result = $object->fetch($id);
|
||||
if ($object->paye)
|
||||
{
|
||||
$result = $object->set_unpaid($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
||||
exit();
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$result = $object->fetch($id);
|
||||
if ($object->paye)
|
||||
{
|
||||
$result = $object->set_unpaid($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
||||
exit();
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Link to a project
|
||||
if ($action == 'classin' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->setProject(GETPOST('projectid'));
|
||||
$object->fetch($id);
|
||||
$object->setProject(GETPOST('projectid'));
|
||||
}
|
||||
|
||||
if ($action == 'setlib' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$object->fetch($id);
|
||||
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// payment mode
|
||||
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// bank account
|
||||
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
||||
$object->fetch($id);
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
$object->fetch($id);
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete social contribution
|
||||
@@ -131,8 +135,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
|
||||
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
|
||||
$amount=price2num(GETPOST('amount'));
|
||||
$actioncode=GETPOST('actioncode');
|
||||
$amount=price2num(GETPOST('amount'));
|
||||
$actioncode=GETPOST('actioncode');
|
||||
|
||||
if (! $dateech)
|
||||
{
|
||||
@@ -166,8 +170,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
||||
$object->date_ech = $dateech;
|
||||
$object->periode = $dateperiod;
|
||||
$object->amount = $amount;
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->fk_project = GETPOST('fk_project');
|
||||
|
||||
$id=$object->create($user);
|
||||
@@ -182,43 +186,43 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
||||
|
||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
|
||||
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
|
||||
$amount=price2num(GETPOST('amount'));
|
||||
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
|
||||
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
|
||||
$amount=price2num(GETPOST('amount'));
|
||||
|
||||
if (! $dateech)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (! $dateperiod)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (empty($amount))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
if (! $dateech)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (! $dateperiod)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (empty($amount))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
elseif (! is_numeric($amount))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$result=$object->fetch($id);
|
||||
$result=$object->fetch($id);
|
||||
|
||||
$object->date_ech = $dateech;
|
||||
$object->periode = $dateperiod;
|
||||
$object->amount = price2num($amount);
|
||||
$object->date_ech = $dateech;
|
||||
$object->periode = $dateperiod;
|
||||
$object->amount = price2num($amount);
|
||||
|
||||
$result=$object->update($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
$result=$object->update($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +285,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
|
||||
|
||||
$form = new Form($db);
|
||||
$formsocialcontrib = new FormSocialContrib($db);
|
||||
$bankaccountstatic = new Account($db);
|
||||
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
|
||||
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Card");
|
||||
@@ -293,51 +298,49 @@ if ($action == 'create')
|
||||
{
|
||||
print load_fiche_titre($langs->trans("NewSocialContribution"));
|
||||
|
||||
$var=false;
|
||||
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
dol_fiche_head();
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Label
|
||||
print "<tr>";
|
||||
print '<td class="titlefieldcreate fieldrequired">';
|
||||
print $langs->trans("Label");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="34" name="label" class="flat" value="'.GETPOST('label').'"></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
// Label
|
||||
print "<tr>";
|
||||
print '<td class="titlefieldcreate fieldrequired">';
|
||||
print $langs->trans("Label");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
|
||||
// Type
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("Type");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode")?GETPOST("actioncode"):'','actioncode',1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
// Type
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("Type");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date end period
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("PeriodEndDate");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("PeriodEndDate");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<td>';
|
||||
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("Amount");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="6" name="amount" class="flat" value="'.GETPOST('amount').'"></td>';
|
||||
print '</tr>';
|
||||
// Amount
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("Amount");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
@@ -354,30 +357,30 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Payment Mode
|
||||
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
|
||||
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
// Payment Mode
|
||||
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
|
||||
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Date due
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("DateDue");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
|
||||
// Date due
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("DateDue");
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
print '<td>';
|
||||
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@@ -387,7 +390,7 @@ if ($action == 'create')
|
||||
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
/* *************************************************************************** */
|
||||
@@ -398,7 +401,7 @@ if ($action == 'create')
|
||||
if ($id > 0)
|
||||
{
|
||||
$object = new ChargeSociales($db);
|
||||
$result=$object->fetch($id);
|
||||
$result=$object->fetch($id);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
@@ -414,7 +417,7 @@ if ($id > 0)
|
||||
|
||||
);
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
|
||||
}
|
||||
|
||||
// Confirmation de la suppression de la charge
|
||||
@@ -445,34 +448,34 @@ if ($id > 0)
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->tax->charges->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->tax->charges->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
@@ -492,7 +495,7 @@ if ($id > 0)
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
|
||||
print "</tr>";
|
||||
|
||||
// Period end date
|
||||
// Period end date
|
||||
print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
|
||||
print "<td>";
|
||||
if ($action == 'edit')
|
||||
@@ -517,51 +520,51 @@ if ($id > 0)
|
||||
}
|
||||
|
||||
// Amount
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
|
||||
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
|
||||
print "</td></tr>";
|
||||
}
|
||||
else {
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
}
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
|
||||
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
|
||||
print "</td></tr>";
|
||||
}
|
||||
else {
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
}
|
||||
|
||||
// Mode of payment
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode')
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editmode') {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
|
||||
} else {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
// Mode of payment
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode')
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editmode') {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
|
||||
} else {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@@ -569,77 +572,106 @@ if ($id > 0)
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
$nbcols = 3;
|
||||
if (! empty($conf->banque->enabled)) {
|
||||
$nbcols ++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Payments
|
||||
*/
|
||||
$sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,";
|
||||
$sql.= "c.code as type_code,c.libelle as paiement_type";
|
||||
$sql.= " c.code as type_code,c.libelle as paiement_type,";
|
||||
$sql.= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
|
||||
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " WHERE p.fk_charge = ".$id;
|
||||
$sql.= " AND p.fk_charge = cs.rowid";
|
||||
$sql.= " AND cs.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_typepaiement = c.id";
|
||||
$sql.= " AND c.entity = " . getEntity('c_paiement');
|
||||
$sql.= " ORDER BY dp DESC";
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$totalpaye = 0;
|
||||
$totalpaye = 0;
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="noborder paymenttable">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("RefPayment").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '</tr>';
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="noborder paymenttable">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("RefPayment").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
if (! empty($conf->banque->enabled)) {
|
||||
print '<td class="liste_titre" align="right">' . $langs->trans('BankAccount') . '</td>';
|
||||
}
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=true;
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print "<tr ".$bc[$var]."><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
|
||||
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
|
||||
print '<td align="right">'.price($objp->amount)."</td>\n";
|
||||
print "</tr>";
|
||||
$totalpaye += $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
|
||||
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
$bankaccountstatic->id = $objp->baid;
|
||||
$bankaccountstatic->ref = $objp->baref;
|
||||
$bankaccountstatic->label = $objp->baref;
|
||||
$bankaccountstatic->number = $objp->banumber;
|
||||
|
||||
print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
|
||||
}
|
||||
if (! empty($conf->accounting->enabled)) {
|
||||
$bankaccountstatic->account_number = $objp->account_number;
|
||||
|
||||
//if ($object->status == ChargeSociales::STATUS_DRAFT)
|
||||
//{
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$accountingjournal->fetch($objp->fk_accountancy_journal);
|
||||
$bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
|
||||
}
|
||||
|
||||
$resteapayer = $object->amount - $totalpaye;
|
||||
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
|
||||
print '<td align="right">';
|
||||
if ($bankaccountstatic->id)
|
||||
print $bankaccountstatic->getNomUrl(1, 'transactions');
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->amount)."</td>\n";
|
||||
print "</tr>";
|
||||
$totalpaye += $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
|
||||
//}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
|
||||
|
||||
$resteapayer = $object->amount - $totalpaye;
|
||||
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
|
||||
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("RemainderToPay")." :</td>";
|
||||
print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
|
||||
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
@@ -83,7 +83,7 @@ class ChargeSociales extends CommonObject
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN (' . getEntity('c_paiement').')';
|
||||
if ($ref) $sql.= " WHERE cs.rowid = ".$ref;
|
||||
else $sql.= " WHERE cs.rowid = ".$id;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
{
|
||||
public $element='paiementcharge'; //!< Id that identify managed objects
|
||||
public $table_element='paiementcharge'; //!< Name of table without prefix where object is stored
|
||||
public $picto = 'payment';
|
||||
|
||||
var $fk_charge;
|
||||
var $datec='';
|
||||
@@ -78,7 +79,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
$now=dol_now();
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
|
||||
|
||||
// Validate parametres
|
||||
if (! $this->datepaye)
|
||||
{
|
||||
@@ -125,7 +126,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge");
|
||||
|
||||
|
||||
// Insere tableau des montants / factures
|
||||
foreach ($this->amounts as $key => $amount)
|
||||
{
|
||||
@@ -137,7 +138,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
// If we want to closed payed invoices
|
||||
if ($closepaidcontrib)
|
||||
{
|
||||
|
||||
|
||||
$contrib=new ChargeSociales($this->db);
|
||||
$contrib->fetch($contribid);
|
||||
$paiement = $contrib->getSommePaiement();
|
||||
@@ -205,6 +206,7 @@ class PaymentSocialContribution extends CommonObject
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."paiementcharge as t)";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
|
||||
$sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id";
|
||||
$sql.= " AND pt.entity = " . getEntity('c_paiement');
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@@ -612,6 +614,68 @@ class PaymentSocialContribution extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->statut,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $status Statut
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
function LibStatut($status,$mode=0)
|
||||
{
|
||||
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
|
||||
|
||||
$langs->load('compta');
|
||||
/*if ($mode == 0)
|
||||
{
|
||||
if ($status == 0) return $langs->trans('ToValidate');
|
||||
if ($status == 1) return $langs->trans('Validated');
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($status == 0) return $langs->trans('ToValidate');
|
||||
if ($status == 1) return $langs->trans('Validated');
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
|
||||
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
|
||||
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
|
||||
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
|
||||
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
|
||||
}
|
||||
if ($mode == 6)
|
||||
{
|
||||
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
|
||||
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
|
||||
}*/
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
|
||||
@@ -133,7 +133,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity = " . getEntity('c_paiement');
|
||||
$sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid";
|
||||
$sql.= " AND cs.entity = ".$conf->entity;
|
||||
if ($year > 0)
|
||||
|
||||
@@ -100,7 +100,7 @@ $bankstatic = new Account($db);
|
||||
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
|
||||
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity = " . getEntity('c_paiement');
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE t.entity = ".$conf->entity;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user