Skip to content

Commit

Permalink
Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git …
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
eldy committed May 7, 2012
2 parents a8307a3 + c2f6a26 commit 0737748
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 149 deletions.
11 changes: 9 additions & 2 deletions htdocs/compta/facture.php
Expand Up @@ -94,6 +94,7 @@
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks


// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer)
{
Expand Down Expand Up @@ -248,7 +249,6 @@
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}

else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
Expand All @@ -257,7 +257,14 @@
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}

else if ($action == 'setpaymentterm' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setconditions' && $user->rights->facture->creer)
{
$object->fetch($id);
Expand Down
5 changes: 4 additions & 1 deletion htdocs/core/class/html.form.class.php
Expand Up @@ -2254,7 +2254,10 @@ function formconfirm($page, $title, $question, $action, $formquestion='', $selec
if ($inputarray.length>0) {
$.each($inputarray, function() {
var inputname = this;
var inputvalue = $("#" + this).val();
var more = \'\';
if ($("#" + this).attr("type") == \'checkbox\') { more = \':checked\'; }
var inputvalue = $("#" + this + more).val();
if (typeof inputvalue == \'undefined\') { inputvalue=\'\'; }
options += \'&\' + inputname + \'=\' + inputvalue;
});
//alert(options);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/tpl/freeproductline_create.tpl.php
Expand Up @@ -75,7 +75,7 @@

<?php if ($conf->service->enabled && $dateSelector) { ?>
<tr <?php echo $bcnd[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="10"' : ' colspan="9s"'); ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="10"' : ' colspan="9"'); ?>>
<?php
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
Expand Down
6 changes: 5 additions & 1 deletion htdocs/langs/en_US/projects.lang
Expand Up @@ -85,7 +85,11 @@ TaskIsNotAffectedToYou=Task not allocated to you
ErrorTimeSpentIsEmpty=Time spent is empty
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent.
IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
CloneProject=Clone project (associated task will be duplicated too)
CloneProject=Clone project
CloneTasks=Clone tasks
CloneContacts=Clone contacts
CloneNotes=Clone notes
CloneFiles=Clone joined files
ConfirmCloneProject=Are you sure to clone this project ?
ProjectReportDate=Change task date according project start date
ErrorShiftTaskDate=Impossible to shift task date according to new project start date
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/fr_FR/main.lang
Expand Up @@ -603,7 +603,7 @@ Before=Avant
After=Après
IPAddress=Adresse IP
Frequency=Fréquence
IM=Messagerie instantannée
IM=Messagerie instantanée
NewAttribute=Nouvel attribut
AttributeCode=Code de l'attribut
OptionalFieldsSetup=Configuration des attributs complémentaires
Expand Down
6 changes: 5 additions & 1 deletion htdocs/langs/fr_FR/projects.lang
Expand Up @@ -85,7 +85,11 @@ TaskIsNotAffectedToYou=Tâche qui ne vous est pas affectée
ErrorTimeSpentIsEmpty=Le temps consommé n'est pas renseigné
ThisWillAlsoRemoveTasks=Cette opération détruira également les tâches du projet (<b>%s</b> tâches actuellement) et le suivi des consommés.
IfNeedToUseOhterObjectKeepEmpty=Si des objets (facture, commande, ...), appartenant à un autre tiers que celui choisi, doivent être liés au projet à créer, laisser vide afin de laisser le projet multi-tiers.
CloneProject=Cloner le projet (les taches associées sont dupliquées également)
CloneProject=Cloner le projet
CloneTasks=Cloner les taches
CloneContacts=Cloner les contacts
CloneNotes=Cloner les notes
CloneFiles=Cloner les pièces jointes
ConfirmCloneProject=Êtes-vous sûr de vouloir cloner ce projet ?
ProjectReportDate=Reporter les dates des taches en fonction de la date de départ.
ErrorShiftTaskDate=Une erreur c'est produite dans le report des dates des taches.
Expand Down
19 changes: 10 additions & 9 deletions htdocs/main.inc.php
Expand Up @@ -777,13 +777,15 @@ function analyse_sql_and_script(&$var, $type)
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
* @return void
*/
function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
{
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
left_menu('', $help_url, '', '', 1, $title);
main_area($title);
}
function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
{
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
if (empty($conf->global->MAIN_HIDE_LEFT_MENU)) {
left_menu('', $help_url, '', '', 1, $title);
}
main_area($title);
}
}


Expand Down Expand Up @@ -1172,11 +1174,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a

/*
* Top menu
*/
*/
$top_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu;
if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php

// Load the top menu manager
// Load the top menu manager (only if not already done)
if (! class_exists('MenuTop'))
{
Expand Down
85 changes: 23 additions & 62 deletions htdocs/projet/class/project.class.php
Expand Up @@ -883,21 +883,24 @@ function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0)
return $projects;
}

/** Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
* @param bool $clone_contact clone contact of project
* @param bool $clone_task clone task of project
* @param bool $clone_file clone file of project
* @param bool $clone_note clone note of project
* @return int New id of clone
*/
function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_file=true,$clone_note=true)
/**
* Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
* @param bool $clone_contact clone contact of project
* @param bool $clone_task clone task of project
* @param bool $clone_file clone file of project
* @param bool $clone_note clone note of project
* @return int New id of clone
*/
function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_file=false,$clone_note=true)
{
global $user,$langs,$conf;

$error=0;

dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_file=".$clone_file." clone_note=".$clone_note);

$now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now()));

$clone_project=new Project($this->db);
Expand All @@ -908,30 +911,18 @@ function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_fi
$clone_project->fetch($fromid);

$orign_dt_start=$clone_project->date_start;


$orign_project_ref=$clone_project->ref;

$clone_project->id=0;
$clone_project->date_start = $now;
if (!(empty($clone_project->date_end)))
{
//Calculate new project end date ragarding difference between original project start date and new start date (now)
$datetime_start = new DateTime();
$datetime_start->setTimestamp($orign_dt_start);
$datetime_now = new DateTime();
$datetime_now->setTimestamp($now);
$diff_dt = $datetime_start->diff($datetime_now);

$datetime_end = new DateTime();
$datetime_end->setTimestamp($clone_project->date_end);
$datetime_end->add($diff_dt);
$clone_project->date_end = $datetime_end->getTimestamp();
$clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start);
}

$clone_project->datec = $now;

if (!$clone_note)
if (! $clone_note)
{
$clone_project->note_private='';
$clone_project->note_public='';
Expand Down Expand Up @@ -1139,11 +1130,12 @@ function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_fi
}


/** Shift project task date from current date to delta
*
* @param timestamp $old_project_dt_start old project start date
* @return int 1 if OK or < 0 if KO
*/
/**
* Shift project task date from current date to delta
*
* @param timestamp $old_project_dt_start old project start date
* @return int 1 if OK or < 0 if KO
*/
function shiftTaskDate($old_project_dt_start)
{
global $user,$langs,$conf;
Expand All @@ -1156,11 +1148,6 @@ function shiftTaskDate($old_project_dt_start)
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;

//convert timestamp to datetime
$old_project_dt_st = new DateTime();
$old_project_dt_st->setTimestamp($old_project_dt_start);
$old_project_dt_st->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side

$tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0);

foreach ($tasksarray as $tasktoshiftdate)
Expand All @@ -1183,39 +1170,13 @@ function shiftTaskDate($old_project_dt_start)
//Calcultate new task start date with difference between old proj start date and origin task start date
if (!empty($tasktoshiftdate->date_start))
{
dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
$orign_task_datetime_start = new DateTime();
$orign_task_datetime_start->setTimestamp($tasktoshiftdate->date_start);
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side effect
$diff_dt_st = $old_project_dt_st->diff($orign_task_datetime_start);

//Project new start date
$datetime_start = new DateTime();
$datetime_start->setTimestamp($this->date_start);
$datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side

//New task start date
$datetime_start->add($diff_dt_st);
$task->date_start = $datetime_start->getTimestamp();
$task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_st);
}

//Calcultate new task end date with difference between origin proj end date and origin task end date
if (!empty($tasktoshiftdate->date_end))
{
$orign_task_datetime_end = new DateTime();
$orign_task_datetime_end->setTimestamp($tasktoshiftdate->date_end);
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect

$diff_dt_end = $old_project_dt_st->diff($orign_task_datetime_end);

//Project new start date
$datetime_end = new DateTime();
$datetime_end->setTimestamp($this->date_start);
$datetime_end->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side

//New task start date
$datetime_end->add($diff_dt_end);
$task->date_end = $datetime_end->getTimestamp();
$task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_st);
}

if ($to_update)
Expand Down
31 changes: 4 additions & 27 deletions htdocs/projet/class/task.class.php
Expand Up @@ -957,7 +957,7 @@ function createFromClone($fromid,$project_id,$parent_task_id,$clone_change_dt=fa

$now=dol_now();

$datec = dol_mktime(0,0,0,idate('m',$now),idate('d',$now),idate('Y',$now));
$datec = $now;

$clone_task=new Task($this->db);

Expand All @@ -980,41 +980,18 @@ function createFromClone($fromid,$project_id,$parent_task_id,$clone_change_dt=fa
$projectstatic->fetch($ori_project_id);

//Origin project strat date
$orign_project_dt_start = new DateTime();
$orign_project_dt_start->setTimestamp($projectstatic->date_start);
$orign_project_dt_start = $projectstatic->date_start;

//Calcultate new task start date with difference between origin proj start date and origin task start date
if (!empty($clone_task->date_start))
{
$orign_task_datetime_start = new DateTime();
$orign_task_datetime_start->setTimestamp($clone_task->date_start);
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
$diff_dt_st = $orign_project_dt_start->diff($orign_task_datetime_start);

//cloned project start date
$datetime_start = new DateTime();
$datetime_start->setTimestamp($now);

//New task start date
$datetime_start->add($diff_dt_st);
$clone_task->date_start = $datetime_start->getTimestamp();
$clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
}

//Calcultate new task end date with difference between origin proj end date and origin task end date
if (!empty($clone_task->date_end))
{
$orign_task_datetime_end = new DateTime();
$orign_task_datetime_end->setTimestamp($clone_task->date_end);
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
$diff_dt_end = $orign_project_dt_start->diff($orign_task_datetime_end);

//cloned project start date
$datetime_end = new DateTime();
$datetime_end->setTimestamp($now);

//New task start date
$datetime_end->add($diff_dt_end);
$clone_task->date_end = $datetime_end->getTimestamp();
$clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
}

}
Expand Down

0 comments on commit 0737748

Please sign in to comment.