L'onglet 'Documents' des propales est fonctionnel + diverses modifications esthétiques

This commit is contained in:
marc_ocebo 2005-06-27 21:47:44 +00:00
parent cea58d9122
commit a16e2ef285
13 changed files with 1420 additions and 1126 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,14 +21,15 @@
* $Source$ * $Source$
*/ */
/** \file htdocs/comm/propal/document.php /**
\file htdocs/comm/propal/document.php
\ingroup propale \ingroup propale
\brief Page de gestion des documents attachées à une proposition commerciale \brief Page de gestion des documents attachées à une proposition commerciale
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require('./pre.inc.php');
require_once("../../propal.class.php"); require_once('../../propal.class.php');
$user->getrights('propale'); $user->getrights('propale');
@ -38,10 +40,12 @@ if (!$user->rights->propale->lire)
llxHeader(); llxHeader();
$propalid=empty($_GET['propalid']) ? 0 : intVal($_GET['propalid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
function do_upload ($upload_dir) function do_upload ($upload_dir)
{ {
global $local_file, $error_msg; global $local_file, $error_msg, $langs;
if (! is_dir($upload_dir)) if (! is_dir($upload_dir))
{ {
@ -49,57 +53,76 @@ function do_upload ($upload_dir)
mkdir($upload_dir, 0755); mkdir($upload_dir, 0755);
} }
if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name']))
{ {
print "Le fichier est valide, et a &eacute;t&eacute; t&eacute;l&eacute;charg&eacute; avec succ&egrave;s.\n"; echo $langs->trans('FileUploaded');
//print_r($_FILES);
} }
else else
{ {
echo "Le fichier n'a pas été téléchargé"; echo $langs->trans('FileNotUploaded');
// print_r($_FILES); }
} }
} /******************************************************************************/
/* Actions */
/******************************************************************************/
if ($propalid > 0)
if ($_GET["id"] > 0)
{ {
$propal = new Propal($db); $propal = new Propal($db);
if ($propal->fetch($_GET["id"])) if ($propal->fetch($propalid))
{ {
$forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
$upload_dir = $conf->propal->dir_output . "/" . $propal->ref ; $propref = str_replace($forbidden_chars, '_', $propal->ref);
$upload_dir = $conf->propal->dir_output.'/'.$propref;
if ( $error_msg ) if ( $error_msg )
{ {
echo "<B>$error_msg</B><BR><BR>"; echo '<B>'.$error_msg.'</B><BR><BR>';
} }
/******************************************************************************/
/* Actions */
/******************************************************************************/
if ($action=='delete') if ($action=='delete')
{ {
$file = $upload_dir . "/" . urldecode($urlfile); $file = $upload_dir . '/' . urldecode($_GET['urlfile']);
dol_delete_file($file); dol_delete_file($file);
} }
if ( $_POST["sendit"] ) if ( $_POST['sendit'] )
{ {
do_upload ($upload_dir); do_upload ($upload_dir);
} }
$h=0;
print '<table width="100%" class="noborder">'; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Card');
$h++;
print "<tr><td><div class=\"titre\">Documents associés à la proposition : ".$propal->ref_url."</div></td>"; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
print "</tr></table>"; $head[$h][1] = $langs->trans('Note');
$h++;
print '<form name="userfile" action="document.php?id='.$propal->id.'" enctype="multipart/form-data" method="POST">'; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$hselected=$h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref);
print_titre($langs->trans('AssociatedDocuments').' '.$propal->ref_url);
print '<form name="userfile" action="document.php?propalid='.$propal->id.'" enctype="multipart/form-data" method="POST">';
print '<input type="hidden" name="max_file_size" value="2000000">'; print '<input type="hidden" name="max_file_size" value="2000000">';
print '<input type="file" name="userfile" size="40" maxlength="80"><br>'; print '<input type="file" name="userfile" size="40" maxlength="80"><br>';
print '<input type="submit" value="'.$langs->trans("Upload").'" name="sendit">'; print '<input type="submit" value="'.$langs->trans('Upload').'" name="sendit">';
print '<input type="submit" value="'.$langs->trans("Cancel").'" name="cancelit"><br>'; print '<input type="submit" value="'.$langs->trans('Cancel').'" name="cancelit"><br>';
print '</form><br>'; print '</form><br>';
clearstatcache(); clearstatcache();
@ -109,38 +132,43 @@ if ($_GET["id"] > 0)
if ($handle) if ($handle)
{ {
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td>'.$langs->trans('Size').'</td>';
print '<td>'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{ {
print '<tr><td>'; $var=!$var;
echo '<a target="_blank" href="'.DOL_URL_ROOT.'/document.php?modulepart=propal&file='.urlencode($propal->ref.'/'.$file).'">'.$file.'</a>'; print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a target="_blank" href="'.DOL_URL_ROOT.'/document.php?modulepart=propal&file='.$propref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n"; print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="right">'.filesize($upload_dir."/".$file). ' bytes</td>'; print '<td align="right">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($upload_dir."/".$file)).'</td>';
print '<td align="center">'; print '<td align="center">';
if ($file == $propal->ref . '.pdf') if ($file == $propref . '.pdf')
{ {
echo '-'; echo '-';
} }
else else
{ {
echo '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?id='.$propal->id.'&action=delete&urlfile='.urlencode($file).'">'.$langs->trans("Delete").'</a>'; echo '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id.'&action=delete&urlfile='.urlencode($file).'">'.$langs->trans('Delete').'</a>';
} }
print "</td></tr>\n"; print "</td></tr>\n";
} }
} }
print '</table>';
print "</table>"; print '<br>';
closedir($handle); closedir($handle);
} }
else else
{ {
print "<p>Impossible d'ouvrir : <b>".$upload_dir."</b>"; print '<p>'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b>';
} }
} }
else else
@ -150,10 +178,10 @@ if ($_GET["id"] > 0)
} }
else else
{ {
print "Erreur"; print 'Erreur';
} }
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>');
?> ?>

View File

@ -27,44 +27,48 @@
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require('./pre.inc.php');
$langs->load("propal"); $langs->load('propal');
$user->getrights('propale'); $user->getrights('propale');
if (!$user->rights->propale->lire) if (!$user->rights->propale->lire)
accessforbidden(); accessforbidden();
require("../../propal.class.php"); require('../../propal.class.php');
/* /*
* *
* *
*/ */
llxHeader(); llxHeader();
if ($_GET["propalid"]) if ($_GET['propalid'])
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET["propalid"]); $propal->fetch($_GET['propalid']);
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($propal->soc_id); $societe->fetch($propal->soc_id);
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Card"); $head[$h][1] = $langs->trans('Card');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans('Note');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans('Info');
$hselected=$h; $hselected=$h;
$h++; $h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref"); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref);
$propal->info($propal->id); $propal->info($propal->id);
@ -72,10 +76,10 @@ if ($_GET["propalid"])
dolibarr_print_object_info($propal); dolibarr_print_object_info($propal);
print '</td></tr></table>'; print '</td></tr></table>';
print "<br></div>"; print '<br></div>';
$db->close(); $db->close();
} }
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>');
?> ?>

View File

@ -29,10 +29,10 @@
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require('./pre.inc.php');
require("../../propal.class.php"); require('../../propal.class.php');
$langs->load("propal"); $langs->load('propal');
$user->getrights('propale'); $user->getrights('propale');
if (!$user->rights->propale->lire) if (!$user->rights->propale->lire)
@ -44,7 +44,7 @@ if (!$user->rights->propale->lire)
*/ */
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
unset($_GET["action"]); unset($_GET['action']);
$socidp = $user->societe_id; $socidp = $user->societe_id;
} }
@ -52,12 +52,11 @@ if ($user->societe_id > 0)
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
if ($_POST["action"] == 'update' && $user->rights->propale->creer) if ($_POST['action'] == 'update' && $user->rights->propale->creer)
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET["propalid"]); $propal->fetch($_GET['propalid']);
$propal->update_note($_POST["note"]); $propal->update_note($_POST['note']);
} }
llxHeader(); llxHeader();
@ -66,35 +65,38 @@ $html = new Form($db);
/* Fin des Actions */ /* Fin des Actions */
/******************************************************************************/ /******************************************************************************/
if ($_GET["propalid"]) if ($_GET['propalid'])
{ {
$propal = new Propal($db); $propal = new Propal($db);
if ( $propal->fetch($_GET["propalid"]) ) if ( $propal->fetch($_GET['propalid']) )
{ {
$societe = new Societe($db); $societe = new Societe($db);
if ( $societe->fetch($propal->soc_id) ) if ( $societe->fetch($propal->soc_id) )
{ {
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Card"); $head[$h][1] = $langs->trans('Card');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans('Note');
$hselected=$h; $hselected=$h;
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++; $h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref"); dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref");
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans('Company').'</td><td>';
if ($societe->client == 1) if ($societe->client == 1)
{ {
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id;
@ -104,23 +106,22 @@ if ($_GET["propalid"])
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
} }
print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td>'.$langs->trans("Status").'</td><td align="left">'.$propal->statut_libelle.'</td></tr>'; print '<td>'.$langs->trans('Status').'</td><td align="left">'.$propal->statut_libelle.'</td></tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td>';
print '<tr><td>'.$langs->trans("Date").'</td><td>'.strftime("%A %d %B %Y",$propal->date); print dolibarr_print_date($propal->date);
if ($propal->fin_validite) if ($propal->fin_validite)
{ {
print " (".strftime("%d %B %Y",$propal->fin_validite).")"; print ' ('.dolibarr_print_date($propal->fin_validite).')';
} }
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Author').'</td><td>';
print '<td>'.$langs->trans("Author").'</td><td>';
$author = new User($db, $propal->user_author_id); $author = new User($db, $propal->user_author_id);
$author->fetch(''); $author->fetch('');
print $author->fullname.'</td></tr>'; print $author->fullname.'</td></tr>';
print '<tr><td valign="top" colspan="4">'.$langs->trans("Note").' :<br>'. nl2br($propal->note)."</td></tr>"; print '<tr><td valign="top" colspan="4">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>';
if ($_GET["action"] == 'edit') if ($_GET['action'] == 'edit')
{ {
print '<form method="post" action="note.php?propalid='.$propal->id.'">'; print '<form method="post" action="note.php?propalid='.$propal->id.'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -129,8 +130,7 @@ if ($_GET["propalid"])
print '</form>'; print '</form>';
} }
print '</table>';
print "</table>";
print '<br>'; print '<br>';
print '</div>'; print '</div>';
@ -139,17 +139,13 @@ if ($_GET["propalid"])
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->propale->creer && $_GET['action'] <> 'edit')
if ($user->rights->propale->creer && $_GET["action"] <> 'edit')
{ {
print "<a class=\"tabAction\" href=\"note.php?propalid=$propal->id&amp;action=edit\">".$langs->trans("Edit")."</a>"; print '<a class="tabAction" href="note.php?propalid='.$propal->id.'&amp;action=edit">'.$langs->trans('Edit').'</a>';
} }
print '</div>';
print "</div>";
} }
} }
} }
$db->close(); $db->close();
llxFooter('$Date$ - $Revision: 1.15 '); llxFooter('$Date$ - $Revision: 1.15 ');

View File

@ -388,6 +388,51 @@ class Form
} }
/**
* \brief Affiche la liste déroulante des projets d'une société donnée
*
*/
function select_projects($socid='', $selected='', $htmlname='projectid')
{
$socid=intVal($socid);
if (empty($socid))
return;
// On recherche les societes
$sql = 'SELECT p.rowid, p.title FROM ';
$sql .= MAIN_DB_PREFIX .'projet as p';
$sql .= ' WHERE fk_soc='.$socid;
$sql .= ' ORDER BY p.title ASC';
$result=$this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if (!empty($selected) && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected>'.$obj->title.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">'.$obj->title.'</option>';
}
$i++;
}
}
print '</select>';
}
else
{
dolibarr_print_error($this->db);
}
}
/** /**
* \brief Retourne la liste des produits * \brief Retourne la liste des produits
* \param selected Produit présélectionné * \param selected Produit présélectionné

View File

@ -8,3 +8,4 @@ DeleteAProject=Supprimer un projet
ConfirmDeleteAProject=Are you sure you want to delete this project ? ConfirmDeleteAProject=Are you sure you want to delete this project ?
LastProjects=Last %s projects LastProjects=Last %s projects
AllProjects=All projects AllProjects=All projects
ShowProject=Show project

View File

@ -32,3 +32,8 @@ NoOpenedPropals=No opened commercial proposals
NoOtherOpenedPropals=No other opened commercial proposals NoOtherOpenedPropals=No other opened commercial proposals
RefProposal=Commercial proposal ref RefProposal=Commercial proposal ref
SendPropalByMail=Send commercial proposal by mail SendPropalByMail=Send commercial proposal by mail
Documents=Documents
FileNotUploaded=The file was not uploaded
FileUploaded=The file was successfully uploaded
AssociatedDocuments=Documents associated with the proposal:
ErrorCantOpenDir=Can't open directory

View File

@ -8,3 +8,4 @@ DeleteAProject=Supprimer un projet
ConfirmDeleteAProject=Êtes-vous sûr de vouloir supprimer ce projet ? ConfirmDeleteAProject=Êtes-vous sûr de vouloir supprimer ce projet ?
LastProjects=Les %s derniers projets LastProjects=Les %s derniers projets
AllProjects=Tous les projets AllProjects=Tous les projets
ShowProject=Afficher projet

View File

@ -32,3 +32,8 @@ NoOpenedPropals=Pas de proposition ouverte
NoOtherOpenedPropals=Pas d'autre proposition ouverte NoOtherOpenedPropals=Pas d'autre proposition ouverte
RefProposal=Réf proposition commerciale RefProposal=Réf proposition commerciale
SendPropalByMail=Envoi proposition commerciale par mail SendPropalByMail=Envoi proposition commerciale par mail
Documents=Documents
FileNotUploaded=Le fichier n'a pas été téléchargé
FileUploaded=Le fichier a été téléchargé avec succés
AssociatedDocuments=Documents associés à la proposition :
ErrorCantOpenDir=Impossible d'ouvrir le répertoire

View File

@ -103,6 +103,32 @@ class Project {
} }
} }
/*
* \brief Met à jour objet projet dans la base
*/
function update()
{
$this->ref = ereg_replace("\"","",stripslashes($this->ref));
$this->ref = ereg_replace("'","",stripslashes($this->ref));
$this->ref = trim($this->ref);
$this->title = ereg_replace("\"","",stripslashes($this->title));
$this->title = ereg_replace("'","",stripslashes($this->title));
$this->title = trim($this->title);
$sql = "UPDATE ".MAIN_DB_PREFIX."projet SET";
$sql .= " ref='".$this->ref."', ";
$sql .= " title='".$this->title."' ";
$sql .= " WHERE rowid=".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
print $this->db->error();
}
}
/* /*
* *
* *

View File

@ -53,6 +53,8 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer)
if ($_POST["action"] == 'update' && $user->rights->projet->creer) if ($_POST["action"] == 'update' && $user->rights->projet->creer)
{ {
if (! $_POST["cancel"]) { if (! $_POST["cancel"]) {
if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"])))
{
$projet = new Project($db); $projet = new Project($db);
$projet->id = $_POST["id"]; $projet->id = $_POST["id"];
$projet->ref = $_POST["ref"]; $projet->ref = $_POST["ref"];
@ -60,6 +62,11 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer)
$projet->update(); $projet->update();
$_GET["id"]=$projet->id; // On retourne sur la fiche projet $_GET["id"]=$projet->id; // On retourne sur la fiche projet
}
else
{
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
}
} else { } else {
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -546,6 +547,68 @@ class Propal
} }
} }
/*
*
*
*
*/
function set_project($user, $project_id)
{
if ($user->rights->propale->creer)
{
//verif que le projet et la société concordent
$sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socidp.' AND p.rowid='.$project_id;
$sqlres = $this->db->query($sql);
if ($sqlres)
{
$numprojet = $this->db->num_rows($sqlres);
if ($numprojet > 0)
{
$this->projetidp=$project_id;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_projet = '.$project_id;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
$this->db->query($sql);
}
}
else
{
dolibarr_print_error($this->db);
}
}
}
/*
*
*
*
*/
function set_contact($user, $contact_id)
{
if ($user->rights->propale->creer)
{
//verif que le contact et la société concordent
$sql = 'SELECT p.idp FROM '.MAIN_DB_PREFIX.'socpeople as p WHERE p.fk_soc = '.$this->socidp.' AND p.idp='.$contact_id;
$sqlres = $this->db->query($sql);
if ($sqlres)
{
$numprojet = $this->db->num_rows($sqlres);
if ($numprojet > 0)
{
$this->projetidp=$project_id;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_soc_contact = '.$contact_id;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
$this->db->query($sql);
}
}
else
{
dolibarr_print_error($this->db);
}
}
}
/* /*
* *
* *

View File

@ -1253,6 +1253,30 @@ class Societe {
return -2; return -2;
} }
} }
/**
* \brief Indique si la société a des projets
* \return bool true si la société a des projets, false sinon
*/
function has_projects()
{
$sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id;
$resql = $this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
$obj = $this->db->fetch_object();
$count = $obj->numproj;
}
else
{
$count = 0;
print $this->db->error();
}
$this->db->free($resql);
return ($count > 0);
}
} }
?> ?>