Qual: Removed duplicate code
This commit is contained in:
parent
5d3f628692
commit
0260a3b1b7
@ -484,9 +484,11 @@ class CommonObject
|
||||
else $sql.= ' SET fk_projet = NULL';
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
|
||||
dol_syslog("CommonObject::set_project sql=".$sql);
|
||||
dol_syslog("CommonObject::setProject sql=".$sql);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->projet_id=$projid;
|
||||
$this->projetidp=$projid;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -2659,16 +2659,16 @@ else
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'classer')
|
||||
if ($_GET['action'] != 'classin')
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&facid='.$fac->id.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classin&facid='.$fac->id.'">';
|
||||
print img_edit($langs->trans('SetProject'),1);
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
if ($_GET['action'] == 'classin')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->projetid,'projetid');
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ if ($_POST["action"] == 'update')
|
||||
$fichinter->ref = $_POST["ref"];
|
||||
|
||||
$fichinter->update($_POST["id"]);
|
||||
$_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre cr<EFBFBD><EFBFBD>e
|
||||
$_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre creee
|
||||
}
|
||||
|
||||
/*
|
||||
@ -195,7 +195,7 @@ if ($_POST['action'] == 'classin')
|
||||
{
|
||||
$fichinter = new Fichinter($db);
|
||||
$fichinter->fetch($_GET['id']);
|
||||
$result=$fichinter->set_project($user, $_POST['projetidp']);
|
||||
$result=$fichinter->setProject($_POST['projetid']);
|
||||
if ($result < 0) dol_print_error($db,$fichinter->error);
|
||||
}
|
||||
|
||||
@ -450,23 +450,10 @@ if ($_GET["action"] == 'create')
|
||||
$langs->load("project");
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
if ($_GET["socid"]) $numprojet = $societe->has_projects();
|
||||
|
||||
if (!$numprojet)
|
||||
$numprojet=select_projects($societe->id,$projetid,'projetidp');
|
||||
if ($numprojet==0)
|
||||
{
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr><td width="130">'.$langs->trans("NoProject").'</td>';
|
||||
|
||||
if ($user->rights->projet->creer)
|
||||
{
|
||||
print '<td><a href='.DOL_URL_ROOT.'/projet/fiche.php?socid='.$societe->id.'&action=create>'.$langs->trans("Add").'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
select_projects($societe->id,'','projetidp');
|
||||
print ' <a href="../projet/fiche.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -522,7 +509,10 @@ elseif ($_GET["id"] > 0)
|
||||
exit;
|
||||
}
|
||||
$fichinter->fetch_client();
|
||||
|
||||
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($fichinter->socid);
|
||||
|
||||
if ($mesg) print $mesg."<br>";
|
||||
|
||||
$head = fichinter_prepare_head($fichinter);
|
||||
@ -565,60 +555,33 @@ elseif ($_GET["id"] > 0)
|
||||
// Societe
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td>".$fichinter->client->getNomUrl(1)."</td></tr>";
|
||||
|
||||
// Projet
|
||||
// Project
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$langs->load("projects");
|
||||
print '<tr><td>';
|
||||
$langs->load('projects');
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project').'</td>';
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($fichinter->socid);
|
||||
$numprojet = $societe->has_projects();
|
||||
if (! $numprojet)
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'classin')
|
||||
{
|
||||
print '</td></tr></table>';
|
||||
print '<td>';
|
||||
print $langs->trans("NoProject").' ';
|
||||
if ($fichinter->brouillon) print '<a class="butAction" href=../projet/fiche.php?socid='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
|
||||
print '</td>';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classin&id='.$fichinter->id.'">';
|
||||
print img_edit($langs->trans('SetProject'),1);
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classin')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp,'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($fichinter->statut == 0 && $user->rights->ficheinter->creer)
|
||||
{
|
||||
if ($_GET['action'] != 'classer' && $fichinter->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&id='.$fichinter->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'projetidp');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($fichinter->projetidp))
|
||||
{
|
||||
print '</td></tr></table>';
|
||||
print '<td colspan="3">';
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($fichinter->projetidp);
|
||||
print '<a href="../projet/fiche.php?id='.$fichinter->projetidp.'" title="'.$langs->trans('ShowProject').'">';
|
||||
print $proj->title;
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else {
|
||||
print '</td></tr></table>';
|
||||
print '<td colspan="3"> </td>';
|
||||
}
|
||||
}
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp,'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -197,6 +197,7 @@ class Fichinter extends CommonObject
|
||||
$this->datev = $obj->datev;
|
||||
$this->datem = $obj->datem;
|
||||
$this->projetidp = $obj->fk_projet;
|
||||
$this->projet_id = $obj->fk_projet;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
@ -374,17 +375,22 @@ class Fichinter extends CommonObject
|
||||
*/
|
||||
function getNextNumRef($soc)
|
||||
{
|
||||
global $db, $langs;
|
||||
global $conf, $db, $langs;
|
||||
$langs->load("interventions");
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/";
|
||||
|
||||
if (defined("FICHEINTER_ADDON") && FICHEINTER_ADDON)
|
||||
if (! empty($conf->global->FICHEINTER_ADDON))
|
||||
{
|
||||
$file = FICHEINTER_ADDON.".php";
|
||||
|
||||
$file = $conf->global->FICHEINTER_ADDON.".php";
|
||||
$classname = $conf->global->FICHEINTER_ADDON;
|
||||
if (! file_exists($dir.$file))
|
||||
{
|
||||
$file='mod_'.$file;
|
||||
$classname='mod_'.$classname;
|
||||
}
|
||||
|
||||
// Chargement de la classe de numerotation
|
||||
$classname = FICHEINTER_ADDON;
|
||||
require_once($dir.$file);
|
||||
|
||||
$obj = new $classname();
|
||||
@ -453,36 +459,6 @@ class Fichinter extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Classe la fiche d'intervention dans un projet
|
||||
* \param project_id Id du projet dans lequel classer la facture
|
||||
*/
|
||||
function set_project($user, $project_id)
|
||||
{
|
||||
if ($user->rights->ficheinter->creer)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinter';
|
||||
$sql.= ' SET fk_projet = '.($project_id <= 0?'NULL':$project_id);
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
|
||||
dol_syslog("Fichinter::set_project sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->projetidp=$project_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("Fichinter::set_project Error ".$this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Fichinter::set_project Error Permission refused");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Efface fiche intervention
|
||||
* \param user Objet du user qui efface
|
||||
|
||||
Loading…
Reference in New Issue
Block a user