diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index 7b62506639015744a93addd4f4b0082a6075498d..fecd48637edf85d927e9b61490bedf666fdd1c7e 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -43,6 +43,7 @@ if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@includ if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only if (! $res) die("Include of main fails"); // Change this following line to use the correct relative path from htdocs +include_once(DOL_DOCUMENT_ROOT.'/core/class/formcompany.class.php'); dol_include_once('/module/class/skeleton_class.class.php'); // Load traductions files requiredby by page @@ -60,6 +61,14 @@ if ($user->societe_id > 0) //accessforbidden(); } +// Load object if id or ref is provided as parameter +$object=new Skeleton_Class($db); +if (($id || $ref) && $action != 'add') +{ + $result=$object->fetch($id,$ref); + if ($result < 0) dol_print_error($db); +} + /******************************************************************* @@ -72,7 +81,6 @@ if ($action == 'add') { $error=0; - $object=new Skeleton_Class($db); /* object_prop_getpost_prop */ $object->prop1=GETPOST("field1"); $object->prop2=GETPOST("field2"); @@ -122,7 +130,7 @@ $form=new Form($db); // Put here content of your page -// Example 1 : Adding jquery code +// Example : Adding jquery code print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { function init_myfunc() @@ -138,13 +146,8 @@ jQuery(document).ready(function() { </script>'; -// Example 2 : Adding links to objects -// The class must extends CommonObject class to have this method available -//$somethingshown=$object->showLinkedObjectBlock(); - - -// Example 3 : List of data -if ($action == 'list') +// Part to show a list +if ($action == 'list' || empty($id)) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -191,6 +194,69 @@ if ($action == 'list') +// Part to edit record +if ($id && $action == 'edit') +{ + dol_fiche_head(); + + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; + print '<input type="hidden" name="action" value="add">'; + + + print '<br>'; + + print '<center><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"></center>'; + + print '</form>'; + + dol_fiche_end(); +} + + + +// Part to show record +if ($id && (empty($action) || $action == 'view')) +{ + dol_fiche_head(); + + + + dol_fiche_end(); + + + // Buttons + print '<div class="tabsAction">'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + if ($user->rights->mymodule->write) + { + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; + } + + if ($user->rights->mymodule->delete) + { + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile + { + print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; + } + else + { + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; + } + } + } + print '</div>'."\n"; + + + // Example 2 : Adding links to objects + // The class must extends CommonObject class to have this method available + //$somethingshown=$object->showLinkedObjectBlock(); + +} + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7b7441ba570a05953ebf933d505cbeaf99879eff..100dd4dfb51cdce0ca84bf272ac310cd400563a6 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -741,7 +741,7 @@ class Project extends CommonObject * * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param string $option Variant ('', 'nolink') - * @param int $addlabel 0=Default, 1=Add label into string + * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string * @return string Chaine avec URL */ function getNomUrl($withpicto=0, $option='', $addlabel=0) @@ -773,7 +773,7 @@ class Project extends CommonObject if ($withpicto) $result.=($lien . img_object($label, $picto) . $lienfin); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien . $this->ref . $lienfin . (($addlabel && $this->title) ? ' - ' . $this->title : ''); + if ($withpicto != 2) $result.=$lien . $this->ref . $lienfin . (($addlabel && $this->title) ? ' - ' . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); return $result; } diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 7ea2a0af1e91beedd90c92f4b18b4108cd08616d..9622f4fa480a401a1747a7c2154ca08b0a94e015 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -156,7 +156,7 @@ print '</div></div></div>'; // Tasks for all resources of all opened projects and time spent for each task/resource print '<div class="fichecenter">'; -$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; +$sql = "SELECT p.ref, p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; @@ -216,7 +216,13 @@ if ( $resql ) print "<tr ".$bc[$var].">"; print '<td>'.$username.'</td>'; - print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a></td>'; + print '<td>'; + $projectstatic->id=$obj->projectid; + $projectstatic->ref=$obj->ref; + $projectstatic->title=$obj->title; + print $projectstatic->getNomUrl(1,'',16); + //print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a>'; + print '</td>'; print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>'; print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>'; print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';