Fix: remove unused parameters
Fix: use dol_clone instead fetch
This commit is contained in:
parent
ec327c5330
commit
a5fc434770
@ -107,7 +107,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
|
|||||||
{
|
{
|
||||||
if ($object->fetch($id) > 0)
|
if ($object->fetch($id) > 0)
|
||||||
{
|
{
|
||||||
$result=$object->createFromClone(GETPOST('socid'),$hookmanager);
|
$result=$object->createFromClone($socid, $hookmanager);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||||
|
|||||||
@ -769,62 +769,51 @@ class Commande extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* 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 $fromid Id of object to clone
|
|
||||||
* @param int $invertdetail Reverse sign of amounts for lines
|
|
||||||
* @param int $socid Id of thirdparty
|
* @param int $socid Id of thirdparty
|
||||||
* @param HookManager $hookmanager Hook manager instance
|
* @param HookManager $hookmanager Hook manager instance
|
||||||
* @return int New id of clone
|
* @return int New id of clone
|
||||||
*/
|
*/
|
||||||
function createFromClone($fromid,$invertdetail=0,$socid=0,$hookmanager=false)
|
function createFromClone($socid=0,$hookmanager=false)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$object=new Commande($this->db);
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Load source object
|
// Load source object
|
||||||
$object->fetch($fromid);
|
$objFrom = dol_clone($this);
|
||||||
$objFrom = $object;
|
|
||||||
|
|
||||||
// Change socid if needed
|
// Change socid if needed
|
||||||
if (! empty($socid) && $socid != $object->socid)
|
if (! empty($socid) && $socid != $this->socid)
|
||||||
{
|
{
|
||||||
$objsoc = new Societe($this->db);
|
$objsoc = new Societe($this->db);
|
||||||
|
|
||||||
if ($objsoc->fetch($socid)>0)
|
if ($objsoc->fetch($socid)>0)
|
||||||
{
|
{
|
||||||
$object->socid = $objsoc->id;
|
$this->socid = $objsoc->id;
|
||||||
$object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
|
$this->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);
|
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
|
||||||
$object->fk_project = '';
|
$this->fk_project = '';
|
||||||
$object->fk_delivery_address = '';
|
$this->fk_delivery_address = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Change product price if multi-prices
|
// TODO Change product price if multi-prices
|
||||||
}
|
}
|
||||||
|
|
||||||
$object->id=0;
|
$this->id=0;
|
||||||
$object->statut=0;
|
$this->statut=0;
|
||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
$object->user_author_id = $user->id;
|
$this->user_author_id = $user->id;
|
||||||
$object->user_valid = '';
|
$this->user_valid = '';
|
||||||
$object->date_creation = '';
|
$this->date_creation = '';
|
||||||
$object->date_validation = '';
|
$this->date_validation = '';
|
||||||
$object->ref_client = '';
|
$this->ref_client = '';
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result=$object->create($user);
|
$result=$this->create($user);
|
||||||
|
if ($result < 0) $error++;
|
||||||
// Other options
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
$this->error=$object->error;
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -833,14 +822,14 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
$parameters=array('objFrom'=>$objFrom);
|
$parameters=array('objFrom'=>$objFrom);
|
||||||
$action='';
|
$action='';
|
||||||
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) $error++;
|
if ($reshook < 0) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('ORDER_CLONE',$object,$user,$langs,$conf);
|
$result=$interface->run_triggers('ORDER_CLONE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
@ -849,7 +838,7 @@ class Commande extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $object->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -79,23 +79,26 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
|
|||||||
// Action clone object
|
// Action clone object
|
||||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
if ( 1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers') )
|
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
|
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result=$object->createFromClone($id, 0, GETPOST('socid'), $hookmanager);
|
if ($object->fetch($id) > 0)
|
||||||
if ($result > 0)
|
{
|
||||||
{
|
$result=$object->createFromClone($socid, $hookmanager);
|
||||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
if ($result > 0)
|
||||||
exit;
|
{
|
||||||
}
|
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||||
else
|
exit;
|
||||||
{
|
}
|
||||||
$mesg='<div class="error">'.$object->error.'</div>';
|
else
|
||||||
$action='';
|
{
|
||||||
}
|
$mesg='<div class="error">'.$object->error.'</div>';
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -98,17 +98,20 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result=$object->createFromClone($id,0,$hookmanager);
|
if ($object->fetch($id) > 0)
|
||||||
if ($result > 0)
|
{
|
||||||
{
|
$result=$object->createFromClone($socid, $hookmanager);
|
||||||
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
|
if ($result > 0)
|
||||||
exit;
|
{
|
||||||
}
|
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
|
||||||
else
|
exit;
|
||||||
{
|
}
|
||||||
$mesg=$object->error;
|
else
|
||||||
$action='';
|
{
|
||||||
}
|
$mesg=$object->error;
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -490,60 +490,65 @@ class Facture extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* 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 $fromid Id of object to clone
|
* @param int $socid Id of thirdparty
|
||||||
* @param int $invertdetail Reverse sign of amounts for lines
|
|
||||||
* @param HookManager $hookmanager Hook manager instance
|
* @param HookManager $hookmanager Hook manager instance
|
||||||
* @return int New id of clone
|
* @return int New id of clone
|
||||||
*/
|
*/
|
||||||
function createFromClone($fromid,$invertdetail=0,$hookmanager=false)
|
function createFromClone($socid=0,$hookmanager=false)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Load source object
|
|
||||||
$objFrom=new Facture($this->db);
|
|
||||||
$objFrom->fetch($fromid);
|
|
||||||
|
|
||||||
// Load new object
|
|
||||||
$object=new Facture($this->db);
|
|
||||||
$object->fetch($fromid);
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$object->id=0;
|
// Load source object
|
||||||
$object->statut=0;
|
$objFrom = dol_clone($this);
|
||||||
|
|
||||||
|
// Change socid if needed
|
||||||
|
if (! empty($socid) && $socid != $this->socid)
|
||||||
|
{
|
||||||
|
$objsoc = new Societe($this->db);
|
||||||
|
|
||||||
|
if ($objsoc->fetch($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 = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Change product price if multi-prices
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->id=0;
|
||||||
|
$this->statut=0;
|
||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
$object->user_author = $user->id;
|
$this->user_author = $user->id;
|
||||||
$object->user_valid = '';
|
$this->user_valid = '';
|
||||||
$object->fk_facture_source = 0;
|
$this->fk_facture_source = 0;
|
||||||
$object->date_creation = '';
|
$this->date_creation = '';
|
||||||
$object->date_validation = '';
|
$this->date_validation = '';
|
||||||
$object->ref_client = '';
|
$this->ref_client = '';
|
||||||
$object->close_code = '';
|
$this->close_code = '';
|
||||||
$object->close_note = '';
|
$this->close_note = '';
|
||||||
$object->products = $object->lines; // Tant que products encore utilise
|
$this->products = $this->lines; // Tant que products encore utilise
|
||||||
|
|
||||||
// Loop on each line of new invoice
|
// Loop on each line of new invoice
|
||||||
foreach($object->lines as $i => $line)
|
foreach($this->lines as $i => $line)
|
||||||
{
|
{
|
||||||
if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
|
if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
|
||||||
{
|
{
|
||||||
unset($object->lines[$i]);
|
unset($this->lines[$i]);
|
||||||
unset($object->products[$i]); // Tant que products encore utilise
|
unset($this->products[$i]); // Tant que products encore utilise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result=$object->create($user);
|
$result=$this->create($user);
|
||||||
|
if ($result < 0) $error++;
|
||||||
// Other options
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
$this->error=$object->error;
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -552,14 +557,14 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
$parameters=array('objFrom'=>$objFrom);
|
$parameters=array('objFrom'=>$objFrom);
|
||||||
$action='';
|
$action='';
|
||||||
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) $error++;
|
if ($reshook < 0) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('BILL_CLONE',$object,$user,$langs,$conf);
|
$result=$interface->run_triggers('BILL_CLONE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
@ -568,7 +573,7 @@ class Facture extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $object->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user