This commit is contained in:
Raphaël Doursenaud 2012-05-24 10:46:18 +02:00
commit ffaadcc930
19 changed files with 164 additions and 95 deletions

View File

@ -1588,6 +1588,7 @@ class Propal extends CommonObject
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->statut = 0; $this->statut = 0;
$this->brouillon = 1;
return 1; return 1;
} }
else else

View File

@ -321,7 +321,7 @@ abstract class CommonObject
$tab=array(); $tab=array();
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id"; $sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id"; // This field contains id of llx_socpeople or id of llx_user
if ($source == 'internal') $sql.=", '-1' as socid"; if ($source == 'internal') $sql.=", '-1' as socid";
if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid"; if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid";
$sql.= ", t.civilite as civility, t.name as lastname, t.firstname, t.email"; $sql.= ", t.civilite as civility, t.name as lastname, t.firstname, t.email";

View File

@ -373,7 +373,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
{ {
include_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); include_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
$projectstatic=new Project($db); $projectstatic=new Project($db);
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,$user->societe_id); $tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
$tmparray=explode(',',$tmps); $tmparray=explode(',',$tmps);
if (! in_array($objectid,$tmparray)) accessforbidden(); if (! in_array($objectid,$tmparray)) accessforbidden();
} }

View File

@ -108,8 +108,10 @@ class doc_generic_order_odt extends ModelePDFCommandes
'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'),
'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'), 'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'),
'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_term'=>$object->cond_reglement, 'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs), 'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),

View File

@ -115,8 +115,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures
'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_creation'=>dol_print_date($object->date_creation,'day'),
'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'),
'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_term'=>$object->cond_reglement, 'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs), 'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),

View File

@ -107,8 +107,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales
'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_creation'=>dol_print_date($object->date_creation,'day'),
'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'),
'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_term'=>$object->cond_reglement, 'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs), 'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),

View File

@ -150,26 +150,29 @@ if ($action == 'add' && $user->rights->ecm->setup)
} }
// Remove file // Remove file
if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') if ($action == 'confirm_deletefile')
{ {
$result=$ecmdir->fetch($section); if (GETPOST('confirm') == 'yes')
if (! $result > 0) {
{ $result=$ecmdir->fetch($section);
dol_print_error($db,$ecmdir->error); if (! $result > 0)
exit; {
} dol_print_error($db,$ecmdir->error);
$relativepath=$ecmdir->getRelativePath(); exit;
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; }
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file); $result=dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
$result=$ecmdir->changeNbOfFiles('-'); $result=$ecmdir->changeNbOfFiles('-');
$action='file_manager';
clearstatcache(); clearstatcache();
}
$action='file_manager';
} }
// Remove directory // Remove directory

View File

@ -450,3 +450,5 @@ ALTER TABLE llx_commande_fournisseur ADD COLUMN extraparams varchar(255) AFTER i
ALTER TABLE llx_facture_fourn ADD COLUMN extraparams varchar(255) AFTER import_key; ALTER TABLE llx_facture_fourn ADD COLUMN extraparams varchar(255) AFTER import_key;
ALTER TABLE llx_boxes ADD COLUMN maxline integer NULL; ALTER TABLE llx_boxes ADD COLUMN maxline integer NULL;
ALTER TABLE llx_product_fournisseur_price MODIFY fk_product_fournisseur integer DEFAULT 0;

View File

@ -211,12 +211,21 @@ foreach($listofmodulesextra as $tablename => $elementtype)
$i=0; $i=0;
while($obj=$db->fetch_object($resql)) while($obj=$db->fetch_object($resql))
{ {
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname; $fieldname=$fieldtype='';
$fieldtype = isset($obj->Type)?$obj->Type:'varchar'; if (preg_match('/mysql/',$db->type))
{
$fieldname=$obj->Field;
$fieldtype=$obj->Type;
}
else
{
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
$fieldtype = isset($obj->Type)?$obj->Type:'varchar';
}
if (empty($fieldname)) continue; if (empty($fieldname)) continue;
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue; if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
$arrayoffieldsfound[$fieldname]=$fieldtype; $arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype);
} }
// If it does not match, we create fields // If it does not match, we create fields
@ -225,14 +234,16 @@ foreach($listofmodulesextra as $tablename => $elementtype)
if (! in_array($code,array_keys($arrayoffieldsfound))) if (! in_array($code,array_keys($arrayoffieldsfound)))
{ {
print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> ";
$type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null';
$field_desc=array( $field_desc=array(
'type'=>'varchar', 'type'=>$type,
'value'=>'', 'value'=>$value,
'attribute'=>'', 'attribute'=>$attribute,
'default'=>'', 'default'=>$default,
'extra'=>'', 'extra'=>$extra,
'null'=>'null' 'null'=>$null
); );
//var_dump($field_desc);exit;
$result=$db->DDLAddField($tableextra,$code,$field_desc,""); $result=$db->DDLAddField($tableextra,$code,$field_desc,"");
if ($result < 0) if ($result < 0)

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
@ -92,7 +92,7 @@ if ($action == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
$ref_fourn=GETPOST("ref_fourn"); $ref_fourn=GETPOST("ref_fourn");
if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn");
$quantity=GETPOST("qty"); $quantity=GETPOST("qty");
$tva_tx=GETPOST('tva_tx','alpha'); $tva_tx=price2num(GETPOST('tva_tx','alpha'));
if (empty($quantity)) if (empty($quantity))
{ {
@ -299,14 +299,17 @@ if ($id || $ref)
} }
else else
{ {
print '<input class="flat" name="ref_fourn" size="12" value="'.($_POST["ref_fourn"]?$_POST["ref_fourn"]:'').'">'; print '<input class="flat" name="ref_fourn" size="12" value="'.(GETPOST("ref_fourn")?GETPOST("ref_fourn"):'').'">';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Vat rate // Vat rate
print '<tr><td class="fieldrequired">'.$langs->trans("VATRate").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("VATRate").'</td>';
print '<td colspan="3">'.$form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc).'</td></tr>'; print '<td colspan="3">';
//print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
print '<input type="text" class="flat" size="5" name="tva_tx" value="'.vatrate(GETPOST("tva_tx")?GETPOST("tva_tx"):$product->tva_tx).'">';
print '</td></tr>';
// Availability // Availability
if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
@ -424,6 +427,7 @@ if ($id || $ref)
// VAT rate // VAT rate
print '<td align="right">'; print '<td align="right">';
print vatrate($productfourn->fourn_tva_tx,true); print vatrate($productfourn->fourn_tva_tx,true);
print '</td>'; print '</td>';
// Price quantity // Price quantity

View File

@ -787,12 +787,19 @@ class Project extends CommonObject
$nblinks = 0; $nblinks = 0;
while ($nblinks < $num) while ($nblinks < $num)
{ {
if (preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) if ($source == 'internal' && preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id'])
{ {
if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; if ($mode == 'read' && $user->rights->projet->lire) $userAccess++;
if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; if ($mode == 'write' && $user->rights->projet->creer) $userAccess++;
if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++;
} }
// Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects.
/*if ($source == 'external' && preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->contact_id == $userRole[$nblinks]['id'])
{
if ($mode == 'read' && $user->rights->projet->lire) $userAccess++;
if ($mode == 'write' && $user->rights->projet->creer) $userAccess++;
if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++;
}*/
$nblinks++; $nblinks++;
} }
} }
@ -836,18 +843,24 @@ class Project extends CommonObject
if ($mode == 0) if ($mode == 0)
{ {
$sql.= " AND ec.element_id = p.rowid AND ( p.public = 1"; $sql.= " AND ec.element_id = p.rowid";
$sql.= " AND ( p.public = 1";
//$sql.= " OR p.fk_user_creat = ".$user->id; //$sql.= " OR p.fk_user_creat = ".$user->id;
$sql.= " OR ( ctc.rowid = ec.fk_c_type_contact"; $sql.= " OR ( ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ec.fk_socpeople = " . $user->id . " ) )"; $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")";
//$sql.= " OR (ctc.source = 'external' AND ec.fk_socpeople = ".($user->contact_id?$user->contact_id:0).")"; // Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects.
$sql.= " )";
$sql.= " ))";
} }
if ($mode == 1) if ($mode == 1)
{ {
$sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ec.element_id = p.rowid";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ec.fk_socpeople = " . $user->id; $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")";
//$sql.= " OR (ctc.source = 'external' AND ec.fk_socpeople = ".($user->contact_id?$user->contact_id:0).")"; // Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects.
$sql.= " )";
} }
if ($mode == 2) if ($mode == 2)
{ {

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -31,14 +32,21 @@ $langs->load("projects");
$langs->load("companies"); $langs->load("companies");
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref= GETPOST('ref'); $ref= GETPOST('ref','alpha');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$project = new Project($db);
if ($ref)
{
$project->fetch(0,$ref);
$id=$project->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $id); $result = restrictedArea($user, 'projet', $id);
@ -49,9 +57,7 @@ $result = restrictedArea($user, 'projet', $id);
// Add new contact // Add new contact
if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer) if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer)
{ {
$result = 0; $result = 0;
$project = new Project($db);
$result = $project->fetch($id); $result = $project->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
@ -81,7 +87,6 @@ if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer)
// bascule du statut d'un contact // bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer) if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer)
{ {
$project = new Project($db);
if ($project->fetch($id)) if ($project->fetch($id))
{ {
$result=$project->swapContactStatus(GETPOST('ligne')); $result=$project->swapContactStatus(GETPOST('ligne'));
@ -95,7 +100,6 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer)
// Efface un contact // Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->projet->creer) if ($_GET["action"] == 'deleteline' && $user->rights->projet->creer)
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
$result = $project->delete_contact($_GET["lineid"]); $result = $project->delete_contact($_GET["lineid"]);
@ -133,8 +137,6 @@ dol_htmloutput_mesg($mesg);
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$project = new Project($db);
if ( $project->fetch($id,$ref) > 0) if ( $project->fetch($id,$ref) > 0)
{ {
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id); if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
@ -211,14 +213,14 @@ if ($id > 0 || ! empty($ref))
$var = false; $var = false;
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">'; print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">'; print '<input type="hidden" name="source" value="internal">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$project->id.'">';
// Ligne ajout pour contact interne // Ligne ajout pour contact interne
print "<tr $bc[$var]>"; print "<tr ".$bc[$var].">";
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print img_object('','user').' '.$langs->trans("Users"); print img_object('','user').' '.$langs->trans("Users");

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -36,6 +37,14 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref= GETPOST('ref'); $ref= GETPOST('ref');
$project = new Project($db);
if (! $project->fetch($id,$ref) > 0)
{
dol_print_error($db);
exit;
}
else $id=$project->id;
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
@ -52,12 +61,6 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name"; if (! $sortfield) $sortfield="name";
$project = new Project($db);
if (! $project->fetch($id,$ref) > 0)
{
dol_print_error($db);
exit;
}
/* /*

View File

@ -46,10 +46,8 @@ if ($conf->commande->enabled) $langs->load("orders");
if ($conf->propal->enabled) $langs->load("propal"); if ($conf->propal->enabled) $langs->load("propal");
if ($conf->ficheinter->enabled) $langs->load("interventions"); if ($conf->ficheinter->enabled) $langs->load("interventions");
$projectid=''; $projectid=GETPOST('id');
$ref=''; $ref=GETPOST('ref');
if (isset($_GET["id"])) { $projectid=$_GET["id"]; }
if (isset($_GET["ref"])) { $ref=$_GET["ref"]; }
if ($projectid == '' && $ref == '') if ($projectid == '' && $ref == '')
{ {
dol_print_error('','Bad parameter'); dol_print_error('','Bad parameter');
@ -59,6 +57,13 @@ if ($projectid == '' && $ref == '')
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$project = new Project($db);
if ($ref)
{
$project->fetch(0,$ref);
$projectid=$project->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;

View File

@ -43,6 +43,13 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti
$mine = GETPOST('mode')=='mine' ? 1 : 0; $mine = GETPOST('mode')=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$project = new Project($db);
if ($ref)
{
$project->fetch(0,$ref);
$id=$project->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
@ -82,8 +89,6 @@ if ($action == 'add' && $user->rights->projet->creer)
$db->begin(); $db->begin();
$project = new Project($db);
$project->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
$project->title = $_POST["title"]; $project->title = $_POST["title"];
$project->socid = $_POST["socid"]; $project->socid = $_POST["socid"];
@ -150,8 +155,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
} }
if (! $error) if (! $error)
{ {
$project = new Project($db); $project->fetch($id);
$project->fetch($_POST["id"]);
$project->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
$project->title = $_POST["title"]; $project->title = $_POST["title"];
@ -174,7 +178,6 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
// Build doc // Build doc
if ($action == 'builddoc' && $user->rights->projet->creer) if ($action == 'builddoc' && $user->rights->projet->creer)
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
if (GETPOST('model')) if (GETPOST('model'))
{ {
@ -202,7 +205,6 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
$result = $project->setValid($user); $result = $project->setValid($user);
@ -214,7 +216,6 @@ if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_close' && GETPOST('confirm') == 'yes') if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
$result = $project->setClose($user); $result = $project->setClose($user);
if ($result <= 0) if ($result <= 0)
@ -225,7 +226,6 @@ if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes') if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
$result = $project->setValid($user); $result = $project->setValid($user);
if ($result <= 0) if ($result <= 0)
@ -236,7 +236,6 @@ if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{ {
$project = new Project($db);
$project->fetch($id); $project->fetch($id);
$result=$project->delete($user); $result=$project->delete($user);
if ($result > 0) if ($result > 0)

View File

@ -35,6 +35,13 @@ $ref=GETPOST('ref','alpha');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
if ($ref)
{
$object->fetch(0,$ref);
$id=$object->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -34,6 +35,13 @@ $ref= GETPOST('ref');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$project = new Project($db);
if ($ref)
{
$project->fetch(0,$ref);
$id=$project->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
@ -47,7 +55,6 @@ $result = restrictedArea($user, 'projet', $id);
if ($action == 'update_public' && $user->rights->projet->creer) if ($action == 'update_public' && $user->rights->projet->creer)
{ {
$project = new Project($db);
$project->fetch($_GET['id']); $project->fetch($_GET['id']);
$db->begin(); $db->begin();
@ -66,7 +73,6 @@ if ($action == 'update_public' && $user->rights->projet->creer)
if ($action == 'update_private' && $user->rights->projet->creer) if ($action == 'update_private' && $user->rights->projet->creer)
{ {
$project = new Project($db);
$project->fetch($_GET['id']); $project->fetch($_GET['id']);
$db->begin(); $db->begin();
@ -99,8 +105,7 @@ $now=dol_now();
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
if ($mesg) print $mesg; dol_htmloutput_mesg($mesg);
if ($project->fetch($id, $ref)) if ($project->fetch($id, $ref))
{ {

View File

@ -42,11 +42,17 @@ $mode = GETPOST('mode', 'alpha');
$mine = ($mode == 'mine' ? 1 : 0); $mine = ($mode == 'mine' ? 1 : 0);
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
if ($ref)
{
$object->fetch(0,$ref);
$id=$object->id;
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'projet', $projectid); $result = restrictedArea($user, 'projet', $id);
if (!$user->rights->projet->lire) accessforbidden();
$progress=GETPOST('progress', 'int'); $progress=GETPOST('progress', 'int');
$label=GETPOST('label', 'alpha'); $label=GETPOST('label', 'alpha');
@ -54,7 +60,6 @@ $description=GETPOST('description', 'alpha');
$userAccess=0; $userAccess=0;
$object = new Project($db);
/* /*

View File

@ -66,8 +66,11 @@ class User extends CommonObject
var $datec; var $datec;
var $datem; var $datem;
//! If this is defined, it is an external user //! If this is defined, it is an external user
var $societe_id; var $societe_id;
var $contact_id;
var $fk_member; var $fk_member;
var $webcal_login; var $webcal_login;