Fix #yogosha235

This commit is contained in:
Laurent Destailleur 2021-03-18 20:27:36 +01:00
parent 640f5f6051
commit 461d748f97
8 changed files with 59 additions and 34 deletions

View File

@ -65,7 +65,6 @@ $objecttype = 'facture_rec';
if ($action == "create" || $action == "add") { if ($action == "create" || $action == "add") {
$objecttype = ''; $objecttype = '';
} }
$result = restrictedArea($user, 'facture', $id, $objecttype);
$projectid = GETPOST('projectid', 'int'); $projectid = GETPOST('projectid', 'int');
$year_date_when = GETPOST('year_date_when'); $year_date_when = GETPOST('year_date_when');
@ -127,6 +126,8 @@ $now = dol_now();
$error = 0; $error = 0;
$result = restrictedArea($user, 'facture', $object->id, $objecttype);
/* /*
* Actions * Actions

View File

@ -138,19 +138,19 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
// retained warranty invoice available type
$retainedWarrantyInvoiceAvailableType = array();
if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
$retainedWarrantyInvoiceAvailableType = explode('+', $conf->global->INVOICE_USE_RETAINED_WARRANTY);
}
// Security check // Security check
$fieldid = (!empty($ref) ? 'ref' : 'rowid'); $fieldid = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
// retained warranty invoice available type
$retainedWarrantyInvoiceAvailableType = array();
if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
$retainedWarrantyInvoiceAvailableType = explode('+', $conf->global->INVOICE_USE_RETAINED_WARRANTY);
}
/* /*

View File

@ -1553,7 +1553,7 @@ class Facture extends CommonInvoice
* @param string $ref Reference of invoice * @param string $ref Reference of invoice
* @param string $ref_ext External reference of invoice * @param string $ref_ext External reference of invoice
* @param int $notused Not used * @param int $notused Not used
* @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice * @param bool $fetch_situation Load also the previous and next situation invoice into $tab_previous_situation_invoice and $tab_next_situation_invoice
* @return int >0 if OK, <0 if KO, 0 if not found * @return int >0 if OK, <0 if KO, 0 if not found
*/ */
public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false)

View File

@ -48,9 +48,14 @@ $action = GETPOST('action', 'aZ09');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'facture', $id);
$object = new Facture($db); $object = new Facture($db);
// Load object
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION);
}
$result = restrictedArea($user, 'facture', $object->id);
/* /*
@ -58,8 +63,6 @@ $object = new Facture($db);
*/ */
if ($action == 'addcontact' && $user->rights->facture->creer) { if ($action == 'addcontact' && $user->rights->facture->creer) {
$result = $object->fetch($id);
if ($result > 0 && $id > 0) { if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
@ -79,14 +82,9 @@ if ($action == 'addcontact' && $user->rights->facture->creer) {
} }
} elseif ($action == 'swapstatut' && $user->rights->facture->creer) { } elseif ($action == 'swapstatut' && $user->rights->facture->creer) {
// Toggle the status of a contact // Toggle the status of a contact
if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne'));
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
} elseif ($action == 'deletecontact' && $user->rights->facture->creer) { } elseif ($action == 'deletecontact' && $user->rights->facture->creer) {
// Deletes a contact // Deletes a contact
$object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) { if ($result >= 0) {

View File

@ -48,12 +48,6 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'facture', $id, '');
// Get parameters // Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -73,11 +67,17 @@ if (!$sortfield) {
} }
$object = new Facture($db); $object = new Facture($db);
if ($object->fetch($id)) { if ($object->fetch($id, $ref)) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref);
} }
// Security check
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'facture', $object->id, '');
/* /*
* Actions * Actions

View File

@ -38,6 +38,25 @@ $langs->loadLangs(array('companies', 'bills'));
$id = GETPOST("facid", "int"); $id = GETPOST("facid", "int");
$ref = GETPOST("ref", 'alpha'); $ref = GETPOST("ref", 'alpha');
$object = new Facture($db);
$extrafields = new ExtraFields($db);
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION);
}
// Security check
$fieldid = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) {
$socid = $user->socid;
}
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
/* /*
* View * View
@ -46,11 +65,10 @@ $ref = GETPOST("ref", 'alpha');
$form = new Form($db); $form = new Form($db);
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl);
llxHeader('', $title, $help_url);
$object = new Facture($db);
$object->fetch($id, $ref);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->info($object->id); $object->info($object->id);

View File

@ -165,6 +165,11 @@ if ($socid > 0) {
} }
} }
$objecttype = 'facture_rec';
$result = restrictedArea($user, 'facture', $object->id, $objecttype);
/* /*
* Actions * Actions
*/ */

View File

@ -41,6 +41,14 @@ $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$object = new Facture($db);
// Load object
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION);
}
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid) { if ($user->socid) {
@ -48,11 +56,6 @@ if ($user->socid) {
} }
$result = restrictedArea($user, 'facture', $id, ''); $result = restrictedArea($user, 'facture', $id, '');
$object = new Facture($db);
$object->fetch($id);
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions