NEW Ask date of invoice when using the Clone feature.

This commit is contained in:
Laurent Destailleur 2019-04-12 12:12:08 +02:00
parent b2da5cedbc
commit cf058e7d3b
12 changed files with 162 additions and 128 deletions

View File

@ -67,7 +67,7 @@ foreach ($object->fields as $key => $val) {
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) access_forbidden();
@ -75,6 +75,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->emailcollector->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php
$debuginfo=''; $debuginfo='';
@ -99,7 +104,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other // Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';

View File

@ -66,8 +66,12 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
$permissionnote=$user->rights->asset->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->asset->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->asset->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
/* /*

View File

@ -61,7 +61,7 @@ foreach($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) access_forbidden();
@ -69,6 +69,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php
/* /*
* Actions * Actions
@ -109,7 +114,6 @@ if (empty($reshook))
/* /*
* View * View
* *

View File

@ -126,6 +126,7 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$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
// Security check // Security check
$fieldid = (! empty($ref) ? 'ref' : 'rowid'); $fieldid = (! empty($ref) ? 'ref' : 'rowid');
@ -160,21 +161,21 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
// if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { {
// $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>'; $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
// } else {
if ($object->fetch($id) > 0) { $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
$result = $object->createFromClone($socid); $objectutil->socid = $socid;
if ($result > 0) { $result = $objectutil->createFromClone($user, $id);
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); if ($result > 0) {
exit(); header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
} else { exit();
setEventMessages($object->error, $object->errors, 'errors'); } else {
$action = ''; $langs->load("errors");
} setEventMessages($object->error, $object->errors, 'errors');
} $action = '';
// } }
} }
// Change status of invoice // Change status of invoice
@ -3631,11 +3632,11 @@ elseif ($id > 0 || ! empty($ref))
{ {
// Create an array for form // Create an array for form
$formquestion = array( $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"), array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1))); );
// Paiement incomplet. On demande si motif = escompte ou autre // Ask confirmatio to clone
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250);
} }
// Call Hook formConfirm // Call Hook formConfirm

View File

@ -965,82 +965,80 @@ class Facture extends CommonInvoice
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $socid Id of thirdparty * @param User $user User that clone
* @return int New id of clone * @param int $fromid Id of object to clone
* @return int New id of clone
*/ */
public function createFromClone($socid = 0) public function createFromClone(User $user, $fromid = 0)
{ {
global $user,$hookmanager, $conf; global $hookmanager;
$error=0; $error=0;
$object=new Facture($this->db);
$this->db->begin(); $this->db->begin();
// get extrafields so they will be clone $object->fetch($fromid);
foreach($this->lines as $line)
$line->fetch_optionals($line->rowid);
// Load source object
$objFrom = clone $this;
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $this->socid) if (! empty($this->socid) && $this->socid != $object->socid)
{ {
$objsoc = new Societe($this->db); $objsoc = new Societe($this->db);
if ($objsoc->fetch($socid)>0) if ($objsoc->fetch($this->socid)>0)
{ {
$this->socid = $objsoc->id; $object->socid = $objsoc->id;
$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); $object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = ''; $object->fk_project = '';
$this->fk_delivery_address = ''; $object->fk_delivery_address = '';
} }
// TODO Change product price if multi-prices // TODO Change product price if multi-prices
} }
$this->id=0; $object->id=0;
$this->statut= self::STATUS_DRAFT; $object->statut= self::STATUS_DRAFT;
// Clear fields // Clear fields
$this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box $object->date = (empty($this->date) ? dol_now() : $this->date);
$this->user_author = $user->id; $object->user_author = $user->id;
$this->user_valid = ''; $object->user_valid = '';
$this->fk_facture_source = 0; $object->fk_facture_source = 0;
$this->date_creation = ''; $object->date_creation = '';
$this->date_modification = ''; $object->date_modification = '';
$this->date_validation = ''; $object->date_validation = '';
$this->ref_client = ''; $object->ref_client = '';
$this->close_code = ''; $object->close_code = '';
$this->close_note = ''; $object->close_note = '';
$this->products = $this->lines; // Tant que products encore utilise $object->products = $object->lines; // For backward compatibility
// Loop on each line of new invoice // Loop on each line of new invoice
foreach($this->lines as $i => $line) foreach($object->lines as $i => $line)
{ {
if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
{ {
unset($this->lines[$i]); unset($object->lines[$i]);
unset($this->products[$i]); // Tant que products encore utilise unset($object->products[$i]); // Tant que products encore utilise
} }
} }
// Create clone // Create clone
$this->context['createfromclone'] = 'createfromclone'; $object->context['createfromclone'] = 'createfromclone';
$result=$this->create($user); $result=$object->create($user);
if ($result < 0) $error++; if ($result < 0) $error++;
else { else {
// copy internal contacts // copy internal contacts
if ($this->copy_linked_contact($objFrom, 'internal') < 0) if ($object->copy_linked_contact($this, 'internal') < 0)
$error++; $error++;
// copy external contacts if same company // copy external contacts if same company
elseif ($objFrom->socid == $this->socid) elseif ($this->socid == $object->socid)
{ {
if ($this->copy_linked_contact($objFrom, 'external') < 0) if ($object->copy_linked_contact($this, 'external') < 0)
$error++; $error++;
} }
} }
@ -1050,20 +1048,20 @@ class Facture extends CommonInvoice
// Hook of thirdparty module // Hook of thirdparty module
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters=array('objFrom'=>$objFrom); $parameters=array('objFrom'=>$this);
$action=''; $action='';
$reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
} }
unset($this->context['createfromclone']); unset($object->context['createfromclone']);
// End // End
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $object->id;
} }
else else
{ {
@ -1556,7 +1554,7 @@ class Facture extends CommonInvoice
$line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$line->fetch_optionals(); $line->fetch_optionals();
$this->lines[$i] = $line; $this->lines[$i] = $line;

View File

@ -196,7 +196,24 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete))
} }
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
{
$objectutil = dol_clone($object); // To avoid to denaturate loaded object when setting some properties for clone
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
$result = $objectutil->createFromClone($id);
if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
exit();
} else {
$langs->load("errors");
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$action = '';
}
}
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
{ {
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
@ -204,26 +221,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)
} }
else else
{ {
if ($object->id > 0) $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
{ //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// Because createFromClone modifies the object, we must clone it so that we can restore it later if error // ...
$orig = clone $object;
$result=$object->createFromClone($user, $object->id); $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if ($result > 0) if (is_object($result) || $result > 0)
{ {
$newid = 0; $newid = 0;
if (is_object($result)) $newid = $result->id; if (is_object($result)) $newid = $result->id;
else $newid = $result; else $newid = $result;
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit; exit;
} }
else else
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$object = $orig; $action='';
$action='';
}
} }
} }
} }

View File

@ -741,18 +741,16 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
/** /**
* Create a clone of instance of object (new instance with same value for properties) * Create a clone of instance of object (new instance with same value for properties)
* With native = 0: Property that are reference are also new object (true clone). This means $this->db is not valid. * With native = 0: Property that are reference are also new object (full isolation clone). This means $this->db of new object is not valid.
* With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db is still valid. * With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db of new object is still valid but point to same this->db than original object.
* *
* @param object $object Object to clone * @param object $object Object to clone
* @param int $native Native method or true method * @param int $native Native method or full isolation method
* @return object Object clone * @return object Clone object
* @see https://php.net/manual/language.oop5.cloning.php * @see https://php.net/manual/language.oop5.cloning.php
*/ */
function dol_clone($object, $native = 0) function dol_clone($object, $native = 0)
{ {
//dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
if (empty($native)) if (empty($native))
{ {
$myclone=unserialize(serialize($object)); $myclone=unserialize(serialize($object));

View File

@ -2525,13 +2525,14 @@ class FactureFournisseur extends CommonInvoice
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param User $user User that clone
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @param int $invertdetail Reverse sign of amounts for lines * @param int $invertdetail Reverse sign of amounts for lines
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid, $invertdetail = 0) public function createFromClone(User $user, $fromid, $invertdetail = 0)
{ {
global $user,$langs; global $langs;
$error=0; $error=0;
@ -2545,13 +2546,13 @@ class FactureFournisseur extends CommonInvoice
$object->statut=self::STATUS_DRAFT; $object->statut=self::STATUS_DRAFT;
// Clear fields // Clear fields
$object->ref_supplier=$langs->trans("CopyOf").' '.$object->ref_supplier; $object->ref_supplier = (empty($this->ref_supplier) ? $langs->trans("CopyOf").' '.$object->ref_supplier : $this->ref_supplier);
$object->author = $user->id; $object->author = $user->id;
$object->user_valid = ''; $object->user_valid = '';
$object->fk_facture_source = 0; $object->fk_facture_source = 0;
$object->date_creation = ''; $object->date_creation = '';
$object->date_validation = ''; $object->date_validation = '';
$object->date = ''; $object->date = (empty($this->date) ? '' : $this->date);
$object->date_echeance = ''; $object->date_echeance = '';
$object->ref_client = ''; $object->ref_client = '';
$object->close_code = ''; $object->close_code = '';

View File

@ -101,6 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture',
$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php $permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php $permissiondellink=$user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php $permissionedit=$user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php
/* /*
@ -138,27 +139,25 @@ if (empty($reshook))
} }
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
{ {
// if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
// {
// $mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>'; if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml');
// } $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// else
// { $result=$objectutil->createFromClone($user, $id);
$result=$object->createFromClone($id); if ($result > 0)
if ($result > 0) {
{ header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
header("Location: ".$_SERVER['PHP_SELF'].'?action=editref_supplier&id='.$result); exit;
exit; }
} else
else {
{ $langs->load("errors");
$langs->load("errors"); setEventMessages($objectutil->error, $objectutil->errors, 'errors');
setEventMessages($langs->trans($object->error), null, 'errors'); $action='';
$action=''; }
}
// }
} }
elseif ($action == 'confirm_valid' && $confirm == 'yes' && elseif ($action == 'confirm_valid' && $confirm == 'yes' &&
@ -2228,11 +2227,11 @@ else
{ {
// Create an array for form // Create an array for form
$formquestion=array( $formquestion=array(
//'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier),
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
); );
// Paiement incomplet. On demande si motif = escompte ou autre // Ask confirmation to clone
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250);
} }
// Confirmation de la validation // Confirmation de la validation

View File

@ -94,7 +94,7 @@ foreach($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) access_forbidden();
@ -102,6 +102,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php
/* /*
* Actions * Actions
@ -117,7 +123,6 @@ if (empty($reshook))
{ {
$error=0; $error=0;
$permissiontoadd = $user->rights->mymodule->write;
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage)) { if (empty($backtopage)) {

View File

@ -74,7 +74,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{ {

View File

@ -63,11 +63,16 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
//if ($user->societe_id > 0) $socid = $user->societe_id; //if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'website', $id); //$result = restrictedArea($user, 'website', $id);
$permissionnote=$user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->websiteaccount->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->websiteaccount->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->websiteaccount->write; // Used by the include of actions_addupdatedelete.inc.php
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.