Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-05-07 18:59:17 +02:00
commit 0737748e48
17 changed files with 100 additions and 149 deletions

View File

@ -94,6 +94,7 @@ $hookmanager->initHooks(array('invoicecard'));
$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)
{
@ -248,7 +249,6 @@ else if ($action == 'setmode' && $user->rights->facture->creer)
$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);
@ -257,7 +257,14 @@ else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
$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);

View File

@ -2254,7 +2254,10 @@ class Form
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);

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -777,13 +777,15 @@ if (! function_exists("llxHeader"))
* @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);
}
}
@ -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'))
{

View File

@ -883,21 +883,24 @@ class Project extends CommonObject
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);
@ -908,30 +911,18 @@ class Project extends CommonObject
$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='';
@ -1139,11 +1130,12 @@ class Project extends CommonObject
}
/** 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;
@ -1156,11 +1148,6 @@ class Project extends CommonObject
$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)
@ -1183,39 +1170,13 @@ class Project extends CommonObject
//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)

View File

@ -957,7 +957,7 @@ class Task extends CommonObject
$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);
@ -980,41 +980,18 @@ class Task extends CommonObject
$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;
}
}

View File

@ -80,7 +80,7 @@ if (GETPOST("cancel") && ! empty($backtopage))
//if cancel and come from clone then delete the cloned project
if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
{
{
$project = new Project($db);
$project->fetch($id);
$result=$project->delete($user);
@ -200,7 +200,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$result=$project->update($user);
$id=$project->id; // On retourne sur la fiche projet
if (GETPOST("reportdate") && ($project->date_start!=$old_start_date))
{
$result=$project->shiftTaskDate($old_start_date);
@ -303,25 +303,11 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi
$idtoclone=$id;
$project = new Project($db);
$project->fetch($idtoclone);
$result=$project->createFromClone($idtoclone,true,true,true,true);
if ($result <= 0)
{
$mesg='<div class="error">'.$project->error.'</div>';
}
else
{
$id=$result;
$action='edit';
$comefromclone=true;
}
}
if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
{
$idtoclone=$id;
$project = new Project($db);
$project->fetch($idtoclone);
$result=$project->createFromClone($idtoclone,true,true,true,true);
$clone_contacts=GETPOST('clone_contacts')?1:0;
$clone_tasks=GETPOST('clone_tasks')?1:0;
$clone_files=GETPOST('clone_files')?1:0;
$clone_notes=GETPOST('clone_notes')?1:0;
$result=$project->createFromClone($idtoclone,$clone_contacts,$clone_tasks,$clone_files,$clone_notes);
if ($result <= 0)
{
$mesg='<div class="error">'.$project->error.'</div>';
@ -372,7 +358,7 @@ if ($action == 'create' && $user->rights->projet->creer)
{
require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php");
$modProject = new $obj;
$defaultref = $modProject->getNextValue($soc,$project);
$defaultref = $modProject->getNextValue($soc,$project);
}
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
@ -482,10 +468,17 @@ else
// Clone confirmation
if ($action == 'clone')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1);
if ($ret == 'html') print '<br>';
$formquestion=array(
'text' => $langs->trans("ConfirmClone"),
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' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_files', 'label' => $langs->trans("CloneFiles"), 'value' => false)
);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$project->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240);
}
if ($action == 'edit' && $userWrite > 0)
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -522,7 +515,7 @@ else
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $form->select_date($project->date_start,'project');
print '<input type="checkbox" name="reportdate" value="yes" ';
if ($comefromclone){print ' checked="checked" ';}
if ($comefromclone){print ' checked="checked" ';}
print '/>'. $langs->trans("ProjectReportDate");
print '</td></tr>';
@ -542,7 +535,7 @@ else
print '<div align="center"><br>';
print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
print '</form>';
}
else
@ -580,7 +573,7 @@ else
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print dol_print_date($project->date_start,'day');
print dol_print_date($project->date_start,'day');
print '</td></tr>';
// Date end
@ -656,7 +649,7 @@ else
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>';
}
}
// Clone
if ($user->rights->projet->creer)
{

View File

@ -167,7 +167,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
// Add line to gantt
$s = "// Add taks id=".$task["task_id"]." level = ".$level."\n";
//$s.= "g.AddElementItem(new JSGantt.ElementItem('task',".$task['task_id'].",'".$name."','".$start_date."', '".$end_date."', '".$task['task_color']."', '', ".$task['task_milestone'].", '".$resources."', ".$percent.", ".($task["task_is_group"]>0?1:0).", ".$parent.", 1".($depend?", ".$depend:"")."));";
$s = "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".$name."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".$percent.", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."'));";
$s = "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".$percent.", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."'));";
echo $s."\n";
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
$id=GETPOST('id','int');
$ref=GETPOST('ref');
$ref=GETPOST('ref','alpha');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
@ -228,7 +228,8 @@ if (count($tasksarray)>0)
if (! empty($conf->use_javascript_ajax))
{
print '<div id="tabs" style="border: 1px solid #ACACAC;">'."\n";
//var_dump($_SESSION);
print '<div id="tabs" class="ganttcontainer" style="border: 1px solid #ACACAC;">'."\n";
include_once(DOL_DOCUMENT_ROOT.'/projet/ganttchart.php');
print '</div>'."\n";
}

View File

@ -2095,7 +2095,7 @@ div.tdlineupdown {
/* ============================================================================== */
div.scroll2 {
width: 582px !important;
width: <?php print isset($_SESSION['dol_screenwidth'])?max($_SESSION['dol_screenwidth']-830,450):'450'; ?>px !important;
}

View File

@ -2355,7 +2355,7 @@ form.listactionsfilter input[type="submit"] {
/* ============================================================================== */
div.scroll2 {
width: 582px !important;
width: <?php print isset($_SESSION['dol_screenwidth'])?max($_SESSION['dol_screenwidth']-830,450):'450'; ?>px !important;
}

View File

@ -2171,7 +2171,7 @@ div.table-val-border-col {
/* ============================================================================== */
div.scroll2 {
width: 582px !important;
width: <?php print isset($_SESSION['dol_screenwidth'])?max($_SESSION['dol_screenwidth']-830,450):'450'; ?>px !important;
}

View File

@ -230,9 +230,9 @@ textarea:disabled {
-moz-border-radius:0px 5px 0px 5px;
-webkit-border-radius:0px 5px 0px 5px;
border-radius:0px 5px 0px 5px;
-moz-box-shadow: 4px 4px 4px #CCC;
-webkit-box-shadow: 4px 4px 4px #CCC;
box-shadow: 4px 4px 4px #CCC;
-moz-box-shadow: 2px 2px 3px #CCC;
-webkit-box-shadow: 2px 2px 3px #CCC;
box-shadow: 2px 2px 3px #CCC;
}
.button:focus {
font-family: <?php print $fontlist ?>;
@ -1327,9 +1327,9 @@ span.tabspan {
-moz-border-radius:0px 5px 0px 5px;
-webkit-border-radius:0px 5px 0px 5px;
border-radius:0px 5px 0px 5px;
-moz-box-shadow: 4px 4px 4px #CCC;
-webkit-box-shadow: 4px 4px 4px #CCC;
box-shadow: 4px 4px 4px #CCC;
-moz-box-shadow: 2px 2px 3px #CCC;
-webkit-box-shadow: 2px 2px 3px #CCC;
box-shadow: 2px 2px 3px #CCC;
}
.butAction:hover {
@ -2382,7 +2382,7 @@ a.cke_dialog_ui_button
/* ============================================================================== */
div.scroll2 {
width: 582px !important;
width: <?php print isset($_SESSION['dol_screenwidth'])?max($_SESSION['dol_screenwidth']-830,450):'450'; ?>px !important;
}

View File

@ -46,7 +46,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{
$canreaduser=($user->admin || ($user->rights->user->user->lire && $user->rights->user->user_advance->readperms));
$caneditselfperms=($user->id == $id && $user->rights->user->self_advance->writeperms);
$caneditperms = (($caneditperms || $caneditselfperms) ? 0 : 1);
$caneditperms = (($caneditperms || $caneditselfperms) ? 1 : 0);
}
// Security check