Works on possibility to change customer when cloning (enable in propal)

New: can send extra input in ajax dialog
This commit is contained in:
Regis Houssin 2011-04-25 10:10:34 +00:00
parent fe11e7ec88
commit da0b70c145
3 changed files with 39 additions and 17 deletions

View File

@ -101,15 +101,15 @@ if (! empty($object->hooks))
} }
// Action clone object // Action clone object
if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["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($_REQUEST["id"]); $result=$object->createFromClone($id,0,GETPOST('socid'));
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -1016,7 +1016,9 @@ if ($id > 0 || ! empty($ref))
// Create an array for form // Create an array for form
$formquestion=array( $formquestion=array(
//'text' => $langs->trans("ConfirmClone"), //'text' => $langs->trans("ConfirmClone"),
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $html->select_company(GETPOST('socid'),'socid','(s.client=1 OR s.client=3)'))
); );
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1);
@ -1570,7 +1572,7 @@ if ($id > 0 || ! empty($ref))
// Clone // Clone
if ($object->type == 0 && $user->rights->propale->creer) if ($object->type == 0 && $user->rights->propale->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=clone&amp;object=propal">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=propal">'.$langs->trans("ToClone").'</a>';
} }
// Delete // Delete

View File

@ -813,12 +813,13 @@ class Propal extends CommonObject
} }
/** /**
* \brief 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 fromid Id of object to clone * @param fromid Id of object to clone
* \param invertdetail Reverse sign of amounts for lines * @param invertdetail Reverse sign of amounts for lines
* \return int New id of clone * @param socid Id of thirdparty
* @return int New id of clone
*/ */
function createFromClone($fromid,$invertdetail=0) function createFromClone($fromid,$invertdetail=0,$socid=0)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -839,12 +840,31 @@ class Propal extends CommonObject
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$objFrom = $object; $objFrom = $object;
$objsoc=new Societe($this->db);
// Change socid if needed
if (! empty($socid) && $socid != $object->socid)
{
if ($objsoc->fetch($socid)>0)
{
$object->socid = $objsoc->id;
$object->cond_reglement_id = $objsoc->cond_reglement_id;
$object->mode_reglement_id = $objsoc->mode_reglement_id;
$object->fk_project = '';
$object->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
else
{
$objsoc->fetch($object->socid);
}
$object->id=0; $object->id=0;
$object->statut=0; $object->statut=0;
require_once(DOL_DOCUMENT_ROOT ."/societe/class/societe.class.php");
$objsoc=new Societe($this->db);
$objsoc->fetch($object->socid); $objsoc->fetch($object->socid);
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$conf->global->PROPALE_ADDON.".php")) if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$conf->global->PROPALE_ADDON.".php"))

View File

@ -739,13 +739,13 @@ class Commande extends CommonObject
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $object->socid) if (! empty($socid) && $socid != $object->socid)
{ {
$socstatic = new Societe($this->db); $objsoc = new Societe($this->db);
if ($socstatic->fetch($socid)>0) if ($objsoc->fetch($socid)>0)
{ {
$object->socid = $socid; $object->socid = $objsoc->id;
$object->cond_reglement_id = $soc->cond_reglement_id; $object->cond_reglement_id = $objsoc->cond_reglement_id;
$object->mode_reglement_id = $soc->mode_reglement_id; $object->mode_reglement_id = $objsoc->mode_reglement_id;
$object->fk_project = ''; $object->fk_project = '';
$object->fk_delivery_address = ''; $object->fk_delivery_address = '';
} }