NEW Ask date of invoice when using the Clone feature.
This commit is contained in:
parent
b2da5cedbc
commit
cf058e7d3b
@ -67,7 +67,7 @@ foreach ($object->fields as $key => $val) {
|
||||
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
|
||||
// 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
|
||||
//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);
|
||||
//$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='';
|
||||
|
||||
|
||||
@ -99,7 +104,7 @@ if (empty($reshook))
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
// 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
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
@ -66,8 +66,12 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -61,7 +61,7 @@ foreach($object->fields as $key => $val)
|
||||
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
|
||||
// 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
|
||||
//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);
|
||||
//$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
|
||||
@ -109,7 +114,6 @@ if (empty($reshook))
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*
|
||||
|
||||
@ -126,6 +126,7 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
|
||||
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.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
|
||||
$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
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) {
|
||||
// if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) {
|
||||
// $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>';
|
||||
// } else {
|
||||
if ($object->fetch($id) > 0) {
|
||||
$result = $object->createFromClone($socid);
|
||||
if ($result > 0) {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
|
||||
exit();
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
// }
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
|
||||
{
|
||||
$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.
|
||||
|
||||
$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
|
||||
$objectutil->socid = $socid;
|
||||
$result = $objectutil->createFromClone($user, $id);
|
||||
if ($result > 0) {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
|
||||
exit();
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Change status of invoice
|
||||
@ -3631,11 +3632,11 @@ elseif ($id > 0 || ! empty($ref))
|
||||
{
|
||||
// Create an array for form
|
||||
$formquestion = array(
|
||||
// 'text' => $langs->trans("ConfirmClone"),
|
||||
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
|
||||
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
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
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' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
|
||||
);
|
||||
// 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, 250);
|
||||
}
|
||||
|
||||
// Call Hook formConfirm
|
||||
|
||||
@ -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
|
||||
* @return int New id of clone
|
||||
* @param User $user User that 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;
|
||||
|
||||
$object=new Facture($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// get extrafields so they will be clone
|
||||
foreach($this->lines as $line)
|
||||
$line->fetch_optionals($line->rowid);
|
||||
|
||||
// Load source object
|
||||
$objFrom = clone $this;
|
||||
$object->fetch($fromid);
|
||||
|
||||
// Change socid if needed
|
||||
if (! empty($socid) && $socid != $this->socid)
|
||||
if (! empty($this->socid) && $this->socid != $object->socid)
|
||||
{
|
||||
$objsoc = new Societe($this->db);
|
||||
|
||||
if ($objsoc->fetch($socid)>0)
|
||||
if ($objsoc->fetch($this->socid)>0)
|
||||
{
|
||||
$this->socid = $objsoc->id;
|
||||
$this->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);
|
||||
$this->fk_project = '';
|
||||
$this->fk_delivery_address = '';
|
||||
$object->socid = $objsoc->id;
|
||||
$object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
|
||||
$object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
|
||||
$object->fk_project = '';
|
||||
$object->fk_delivery_address = '';
|
||||
}
|
||||
|
||||
// TODO Change product price if multi-prices
|
||||
}
|
||||
|
||||
$this->id=0;
|
||||
$this->statut= self::STATUS_DRAFT;
|
||||
$object->id=0;
|
||||
$object->statut= self::STATUS_DRAFT;
|
||||
|
||||
// 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
|
||||
$this->user_author = $user->id;
|
||||
$this->user_valid = '';
|
||||
$this->fk_facture_source = 0;
|
||||
$this->date_creation = '';
|
||||
$this->date_modification = '';
|
||||
$this->date_validation = '';
|
||||
$this->ref_client = '';
|
||||
$this->close_code = '';
|
||||
$this->close_note = '';
|
||||
$this->products = $this->lines; // Tant que products encore utilise
|
||||
$object->date = (empty($this->date) ? dol_now() : $this->date);
|
||||
$object->user_author = $user->id;
|
||||
$object->user_valid = '';
|
||||
$object->fk_facture_source = 0;
|
||||
$object->date_creation = '';
|
||||
$object->date_modification = '';
|
||||
$object->date_validation = '';
|
||||
$object->ref_client = '';
|
||||
$object->close_code = '';
|
||||
$object->close_note = '';
|
||||
$object->products = $object->lines; // For backward compatibility
|
||||
|
||||
// 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($this->products[$i]); // Tant que products encore utilise
|
||||
unset($object->lines[$i]);
|
||||
unset($object->products[$i]); // Tant que products encore utilise
|
||||
}
|
||||
}
|
||||
|
||||
// Create clone
|
||||
$this->context['createfromclone'] = 'createfromclone';
|
||||
$result=$this->create($user);
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
$result=$object->create($user);
|
||||
if ($result < 0) $error++;
|
||||
else {
|
||||
// copy internal contacts
|
||||
if ($this->copy_linked_contact($objFrom, 'internal') < 0)
|
||||
if ($object->copy_linked_contact($this, 'internal') < 0)
|
||||
$error++;
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
@ -1050,20 +1048,20 @@ class Facture extends CommonInvoice
|
||||
// Hook of thirdparty module
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('objFrom'=>$objFrom);
|
||||
$parameters=array('objFrom'=>$this);
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->context['createfromclone']);
|
||||
unset($object->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
return $object->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1556,7 +1554,7 @@ class Facture extends CommonInvoice
|
||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$line->fetch_optionals();
|
||||
$line->fetch_optionals();
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
|
||||
@ -196,7 +196,24 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete))
|
||||
}
|
||||
|
||||
// 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'))
|
||||
{
|
||||
@ -204,26 +221,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($object->id > 0)
|
||||
{
|
||||
// Because createFromClone modifies the object, we must clone it so that we can restore it later if error
|
||||
$orig = clone $object;
|
||||
$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'));
|
||||
// ...
|
||||
|
||||
$result=$object->createFromClone($user, $object->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$newid = 0;
|
||||
if (is_object($result)) $newid = $result->id;
|
||||
else $newid = $result;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$object = $orig;
|
||||
$action='';
|
||||
}
|
||||
$result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
|
||||
if (is_object($result) || $result > 0)
|
||||
{
|
||||
$newid = 0;
|
||||
if (is_object($result)) $newid = $result->id;
|
||||
else $newid = $result;
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
* With native = 0: Property that are reference are also new object (true clone). This means $this->db 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 = 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 of new object is still valid but point to same this->db than original object.
|
||||
*
|
||||
* @param object $object Object to clone
|
||||
* @param int $native Native method or true method
|
||||
* @return object Object clone
|
||||
* @param int $native Native method or full isolation method
|
||||
* @return object Clone object
|
||||
* @see https://php.net/manual/language.oop5.cloning.php
|
||||
*/
|
||||
function dol_clone($object, $native = 0)
|
||||
{
|
||||
//dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
|
||||
|
||||
if (empty($native))
|
||||
{
|
||||
$myclone=unserialize(serialize($object));
|
||||
|
||||
@ -2525,13 +2525,14 @@ class FactureFournisseur extends CommonInvoice
|
||||
/**
|
||||
* 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 $invertdetail Reverse sign of amounts for lines
|
||||
* @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;
|
||||
|
||||
@ -2545,13 +2546,13 @@ class FactureFournisseur extends CommonInvoice
|
||||
$object->statut=self::STATUS_DRAFT;
|
||||
|
||||
// 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->user_valid = '';
|
||||
$object->fk_facture_source = 0;
|
||||
$object->date_creation = '';
|
||||
$object->date_validation = '';
|
||||
$object->date = '';
|
||||
$object->date = (empty($this->date) ? '' : $this->date);
|
||||
$object->date_echeance = '';
|
||||
$object->ref_client = '';
|
||||
$object->close_code = '';
|
||||
|
||||
@ -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
|
||||
$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
|
||||
$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
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
|
||||
{
|
||||
// if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
|
||||
// {
|
||||
// $mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
$result=$object->createFromClone($id);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?action=editref_supplier&id='.$result);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans($object->error), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
// }
|
||||
$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.
|
||||
|
||||
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'));
|
||||
|
||||
$result=$objectutil->createFromClone($user, $id);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
elseif ($action == 'confirm_valid' && $confirm == 'yes' &&
|
||||
@ -2228,11 +2227,11 @@ else
|
||||
{
|
||||
// Create an array for form
|
||||
$formquestion=array(
|
||||
//'text' => $langs->trans("ConfirmClone"),
|
||||
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
|
||||
array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier),
|
||||
array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
|
||||
);
|
||||
// Paiement incomplet. On demande si motif = escompte ou autre
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
// 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, 250);
|
||||
}
|
||||
|
||||
// Confirmation de la validation
|
||||
|
||||
@ -94,7 +94,7 @@ foreach($object->fields as $key => $val)
|
||||
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
|
||||
// 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
|
||||
//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);
|
||||
//$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
|
||||
@ -117,7 +123,6 @@ if (empty($reshook))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$permissiontoadd = $user->rights->mymodule->write;
|
||||
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
|
||||
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
|
||||
if (empty($backtopage)) {
|
||||
|
||||
@ -74,7 +74,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// 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))
|
||||
{
|
||||
|
||||
@ -63,11 +63,16 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_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
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// 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.
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user