forked from Wavyzz/dolibarr
Fix several bugs reported by scrutinizer
This commit is contained in:
@@ -55,7 +55,7 @@ if ($action == "set")
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
$id=GETPOST('PRELEVEMENT_ID_BANKACCOUNT','int');
|
||||
$account = new Account($db, $id);
|
||||
$account = new Account($db);
|
||||
|
||||
if($account->fetch($id)>0)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ print "<br>\n";
|
||||
$template_dir = DOL_DOCUMENT_ROOT.'/core/tpl/';
|
||||
|
||||
$interfaces = new Interfaces($db);
|
||||
$triggers = $interfaces->getTriggersList(0,'priority');
|
||||
$triggers = $interfaces->getTriggersList();
|
||||
|
||||
print '<table class="noborder">
|
||||
<tr class="liste_titre">
|
||||
|
||||
@@ -65,7 +65,7 @@ llxHeader('',$langs->trans("Categories"),$help_url);
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'setup');
|
||||
|
||||
$head = categoriesadmin_prepare_head(null);
|
||||
$head = categoriesadmin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category');
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ else if ($id || $ref)
|
||||
llxHeader("","",$langs->trans("Member"));
|
||||
|
||||
|
||||
$head=member_prepare_head($member, $user);
|
||||
$head=member_prepare_head($member);
|
||||
$titre=$langs->trans("Member");
|
||||
$picto='user';
|
||||
dol_fiche_head($head, 'category', $titre,0,$picto);
|
||||
@@ -471,7 +471,7 @@ else if ($id || $ref)
|
||||
llxHeader("","",$langs->trans("Contact"));
|
||||
|
||||
|
||||
$head=contact_prepare_head($object, $user);
|
||||
$head=contact_prepare_head($object);
|
||||
$titre=$langs->trans("ContactsAddresses");
|
||||
$picto='contact';
|
||||
dol_fiche_head($head, 'category', $titre,0,$picto);
|
||||
|
||||
@@ -258,9 +258,10 @@ class ActionComm extends CommonObject
|
||||
* Load object from database
|
||||
*
|
||||
* @param int $id Id of action to get
|
||||
* @param string $ref Ref of action to get
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@@ -286,7 +287,9 @@ class ActionComm extends CommonObject
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
|
||||
$sql.= " WHERE a.id=".$id." AND a.fk_action=c.id";
|
||||
$sql.= " WHERE a.fk_action=c.id";
|
||||
if ($ref) $sql.= " AND a.id=".$ref; // No field ref, we use id
|
||||
else $sql.= " AND a.id=".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
@@ -327,11 +327,11 @@ if ($id > 0)
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editconditions')
|
||||
{
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_id,'cond_reglement_id',-1,1);
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id',1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_id,'none');
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none');
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
@@ -338,9 +338,10 @@ class Account extends CommonObject
|
||||
/**
|
||||
* Create bank account into database
|
||||
*
|
||||
* @param User $user Object user making creation
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
function create()
|
||||
function create($user='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@@ -665,10 +666,9 @@ class Account extends CommonObject
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ if ($_POST["action"] == 'add')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$id = $account->create($user->id);
|
||||
$id = $account->create($user);
|
||||
if ($id > 0)
|
||||
{
|
||||
$_GET["id"]=$id; // Force chargement page en mode visu
|
||||
|
||||
@@ -222,13 +222,16 @@ class Deplacement extends CommonObject
|
||||
* Load an object from database
|
||||
*
|
||||
* @param int $id Id of record to load
|
||||
* @param string $ref Ref of record
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
$sql.= " WHERE entity IN (".getEntity('deplacement').")";
|
||||
if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'";
|
||||
else $sql.= " AND id = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@@ -88,7 +88,7 @@ if ($object->id)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head=trip_prepare_head($object, $user);
|
||||
$head=trip_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
|
||||
|
||||
|
||||
@@ -171,11 +171,12 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
|
||||
}
|
||||
|
||||
// Delete line
|
||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) {
|
||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$result = $object->deleteline($_GET ['lineid'], $user);
|
||||
$result = $object->deleteline(GETPOST('lineid'));
|
||||
if ($result > 0) {
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
@@ -203,14 +204,16 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
||||
}
|
||||
|
||||
// Delete link of credit note to invoice
|
||||
else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) {
|
||||
else if ($action == 'unlinkdiscount' && $user->rights->facture->creer)
|
||||
{
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$result = $discount->fetch($_GET ["discountid"]);
|
||||
$result = $discount->fetch(GETPOST("discountid"));
|
||||
$discount->unlink_invoice();
|
||||
}
|
||||
|
||||
// Validation
|
||||
else if ($action == 'valid' && $user->rights->facture->creer) {
|
||||
else if ($action == 'valid' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
// On verifie signe facture
|
||||
@@ -229,7 +232,8 @@ else if ($action == 'valid' && $user->rights->facture->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'set_thirdparty' && $user->rights->facture->creer) {
|
||||
else if ($action == 'set_thirdparty' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->setValueFrom('fk_soc', $socid);
|
||||
|
||||
@@ -237,12 +241,14 @@ else if ($action == 'set_thirdparty' && $user->rights->facture->creer) {
|
||||
exit();
|
||||
}
|
||||
|
||||
else if ($action == 'classin' && $user->rights->facture->creer) {
|
||||
else if ($action == 'classin' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->setProject($_POST['projectid']);
|
||||
}
|
||||
|
||||
else if ($action == 'setmode' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setmode' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
if ($result < 0)
|
||||
@@ -268,7 +274,8 @@ else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
|
||||
if ($result < 0) dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
else if ($action == 'setconditions' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setconditions' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->cond_reglement_code = 0; // To clean property
|
||||
$object->cond_reglement_id = 0; // To clean property
|
||||
@@ -283,7 +290,8 @@ else if ($action == 'setconditions' && $user->rights->facture->creer) {
|
||||
if ($result < 0) dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
else if ($action == 'setpaymentterm' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setpaymentterm' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']);
|
||||
if ($object->date_lim_reglement < $object->date) {
|
||||
@@ -295,7 +303,8 @@ else if ($action == 'setpaymentterm' && $user->rights->facture->creer) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setrevenuestamp' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->revenuestamp = GETPOST('revenuestamp');
|
||||
$result = $object->update($user);
|
||||
@@ -305,16 +314,19 @@ else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) {
|
||||
}
|
||||
|
||||
// bank account
|
||||
else if ($action == 'setbankaccount' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setbankaccount' && $user->rights->facture->creer)
|
||||
{
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setremisepercent' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setremisepercent' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->set_remise($user, $_POST['remise_percent']);
|
||||
}
|
||||
|
||||
else if ($action == "setabsolutediscount" && $user->rights->facture->creer) {
|
||||
else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
|
||||
{
|
||||
// POST[remise_id] ou POST[remise_id_for_payment]
|
||||
if (! empty($_POST["remise_id"])) {
|
||||
$ret = $object->fetch($id);
|
||||
@@ -339,7 +351,8 @@ else if ($action == "setabsolutediscount" && $user->rights->facture->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'set_ref_client' && $user->rights->facture->creer) {
|
||||
else if ($action == 'set_ref_client' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->set_ref_client($_POST['ref_client']);
|
||||
}
|
||||
@@ -359,7 +372,8 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
|
||||
{
|
||||
$idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY';
|
||||
$idprof = 'idprof' . $i;
|
||||
if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) {
|
||||
if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory))
|
||||
{
|
||||
if (! $error)
|
||||
$langs->load("errors");
|
||||
$error ++;
|
||||
@@ -376,7 +390,8 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
|
||||
}
|
||||
|
||||
// Check for warehouse
|
||||
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) {
|
||||
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||
{
|
||||
if (! $idwarehouse || $idwarehouse == - 1) {
|
||||
$error ++;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors');
|
||||
@@ -412,7 +427,8 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
|
||||
}
|
||||
|
||||
// Go back to draft status (unvalidate)
|
||||
else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) {
|
||||
else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
|
||||
{
|
||||
$idwarehouse = GETPOST('idwarehouse');
|
||||
|
||||
$object->fetch($id);
|
||||
@@ -426,7 +442,8 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) {
|
||||
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||
{
|
||||
if (! $idwarehouse || $idwarehouse == - 1) {
|
||||
$error ++;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors');
|
||||
@@ -460,7 +477,8 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
|
||||
$ventilExportCompta = $object->getVentilExportCompta();
|
||||
|
||||
// On verifie si aucun paiement n'a ete effectue
|
||||
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
|
||||
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
|
||||
{
|
||||
$result=$object->set_draft($user, $idwarehouse);
|
||||
if ($result<0) setEventMessage($object->error,'errors');
|
||||
|
||||
@@ -484,12 +502,14 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
|
||||
}
|
||||
|
||||
// Classify "paid"
|
||||
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) {
|
||||
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
if ($result<0) setEventMessage($object->error,'errors');
|
||||
} // Classif "paid partialy"
|
||||
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) {
|
||||
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$close_code = $_POST["close_code"];
|
||||
$close_note = $_POST["close_note"];
|
||||
|
||||
@@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
$langs->load("bills");
|
||||
$langs->load("companies");
|
||||
|
||||
$id=GETPOST('id');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@@ -39,8 +41,8 @@ $langs->load("companies");
|
||||
llxHeader();
|
||||
|
||||
$paiement = new Paiement($db);
|
||||
$paiement->fetch($_GET["id"], $user);
|
||||
$paiement->info($_GET["id"]);
|
||||
$paiement->fetch($id);
|
||||
$paiement->info($id);
|
||||
|
||||
$head = payment_prepare_head($paiement);
|
||||
|
||||
|
||||
@@ -3043,7 +3043,7 @@ class Form
|
||||
* @param int $page Page
|
||||
* @param string $selected Id condition pre-selectionne
|
||||
* @param string $htmlname Name of select html field
|
||||
* @param int $addempty Ajoute entree vide
|
||||
* @param int $addempty Add empty entry
|
||||
* @return void
|
||||
*/
|
||||
function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id', $addempty=0)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
|
||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||
|
||||
ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer;
|
||||
|
||||
ALTER TABLE llx_propal ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_commande ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
@@ -26,6 +27,8 @@ ALTER TABLE llx_product ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_fichinter ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_bank_account ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
|
||||
|
||||
ALTER TABLE llx_fichinter ADD COLUMN ref_ext varchar(255);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ create table llx_bank_account
|
||||
ref varchar(12) NOT NULL,
|
||||
label varchar(30) NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
fk_user_author integer,
|
||||
fk_user_modif integer,
|
||||
bank varchar(60),
|
||||
code_banque varchar(8),
|
||||
code_guichet varchar(6),
|
||||
|
||||
Reference in New Issue
Block a user