Skip to content

Commit

Permalink
Management of the "Copy of" when cloning projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 16, 2016
1 parent 30e6dd9 commit ee1ee1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.facture.class.php
Expand Up @@ -1032,7 +1032,7 @@ public function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
// Check parameters
if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->ref_supplier))
{
$this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("RefSupplier"));
$this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("RefSupplier")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf"));
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/main.lang
Expand Up @@ -737,6 +737,7 @@ Miscellaneous=Miscellaneous
Calendar=Calendar
GroupBy=Group by...
ViewFlatList=View flat list
RemoveString=Remove string '%s'
# Week day
Monday=Monday
Tuesday=Tuesday
Expand Down
4 changes: 2 additions & 2 deletions htdocs/projet/card.php
Expand Up @@ -661,7 +661,7 @@ function change_percent()
{
$formquestion=array(
'text' => $langs->trans("ConfirmClone"),
array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None")),
array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')),
array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
Expand All @@ -670,7 +670,7 @@ function change_percent()
array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
);

print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590);
}


Expand Down
8 changes: 8 additions & 0 deletions htdocs/projet/class/project.class.php
Expand Up @@ -705,6 +705,13 @@ function setValid($user)

if ($this->statut != 1)
{
// Check parameters
if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title))
{
$this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("Label")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf"));
return -1;
}

$this->db->begin();

$sql = "UPDATE " . MAIN_DB_PREFIX . "projet";
Expand Down Expand Up @@ -1196,6 +1203,7 @@ function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_pr
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';

$clone_project->ref=$defaultref;
$clone_project->title=$langs->trans("CopyOf").' '.$clone_project->title;

// Create clone
$result=$clone_project->create($user,$notrigger);
Expand Down

0 comments on commit ee1ee1e

Please sign in to comment.