From 74bbb606da8137105c4c9b2d15eceefcda7002bc Mon Sep 17 00:00:00 2001
From: "vincent@cubedesigners.com"
Date: Mon, 17 Jan 2011 15:16:05 +0000
Subject: [PATCH]
---
inc/commons/DAO/_common.php | 1 +
.../DAO/class.common.dao.fichier.php} | 2 +-
.../Metier/class.extranet.fichier.php | 0
inc/commons/class.common.droits.php | 17 +++
inc/commons/class.common.url.php | 49 +++++++-
.../Controlleur/class.extranet.url.php | 39 -------
inc/ws/Controlleur/class.ws.ajax.php | 108 ++++++++++++++++++
7 files changed, 171 insertions(+), 45 deletions(-)
rename inc/{extranet/DAO/class.extranet.dao.fichier.php => commons/DAO/class.common.dao.fichier.php} (94%)
rename inc/{extranet => commons}/Metier/class.extranet.fichier.php (100%)
diff --git a/inc/commons/DAO/_common.php b/inc/commons/DAO/_common.php
index 37a35d23c..47479840e 100644
--- a/inc/commons/DAO/_common.php
+++ b/inc/commons/DAO/_common.php
@@ -4,5 +4,6 @@ $__autoload['commonDAOUtilisateur'] = dirname(__FILE__) . '/class.common.dao.uti
$__autoload['commonDAOEquipier'] = dirname(__FILE__) . '/class.common.dao.equipier.php';
$__autoload['commonDAOClient'] = dirname(__FILE__) . '/class.common.dao.client.php';
$__autoload['commonDAOEntreprise'] = dirname(__FILE__) . '/class.common.dao.entreprise.php';
+$__autoload['commonDAOFichier'] = dirname(__FILE__) . '/class.common.dao.fichier.php';
?>
\ No newline at end of file
diff --git a/inc/extranet/DAO/class.extranet.dao.fichier.php b/inc/commons/DAO/class.common.dao.fichier.php
similarity index 94%
rename from inc/extranet/DAO/class.extranet.dao.fichier.php
rename to inc/commons/DAO/class.common.dao.fichier.php
index e494baa1d..74e7f5f7e 100644
--- a/inc/extranet/DAO/class.extranet.dao.fichier.php
+++ b/inc/commons/DAO/class.common.dao.fichier.php
@@ -1,5 +1,5 @@
user->grade;
+ }elseif(MODE=='ws'){
+ $val=$core->user->ws_grade;
+ }
+ if ($val < $grade) {
+ if (!$error) {
+ return false;
+ }
+ commonDroits::error();
+ }
+ }
+
public static function recherche($page)
{
global $core;
diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php
index acd1be616..5372ea1d7 100644
--- a/inc/commons/class.common.url.php
+++ b/inc/commons/class.common.url.php
@@ -289,7 +289,7 @@ class commonUrl {
public static function fichiers($args)
{
global $core;
- extranetDroits::min(0);
+ commonDroits::min(0);
$settings = $core->user->getSettings('fichiers');
@@ -365,7 +365,7 @@ class commonUrl {
public static function listeFichiers($settings = null)
{
global $core;
- extranetDroits::min(0);
+ wsDroits::min(0);
if ($core->user->grade <= 0) {
$entreprise = $core->user->entreprise;
} else {
@@ -424,7 +424,7 @@ class commonUrl {
array_shift($args);
$path = implode('/', $args);
$utilisateur_id = array_shift($args);
- extranetDroits::telecharger($utilisateur_id);
+ wsDroits::telecharger($utilisateur_id);
$dir = md5($path . (rand(1, 235548684) * 50.5));
$nom = array_pop($args);
@mkdir(ROOT . '/cache/download/' . $dir, 0755, true);
@@ -478,7 +478,7 @@ class commonUrl {
if (!$for) {
$mail->to = TEAM_EMAIL;
$mail->subject = '[' . EMAIL_SUBJECT . '] Nouveaux fichiers uploadés par ' . $core->user->prenom . ' ' . $core->user->nom;
- $body = 'Tous les fichiers de ' . $core->user->prenom . ' ' . $core->user->nom . ' : http://extranet.cubedesigners.com/fichiers/' . $core->user->utilisateur_id . "\n\n";
+ $body = 'Tous les fichiers de ' . $core->user->prenom . ' ' . $core->user->nom . ' : http://'.$_SERVER['HTTP_HOST'].'/fichiers/' . $core->user->utilisateur_id . "\n\n";
$body .= 'Fichiers chargés : ' . "\n";
foreach($_SESSION['files_uploaded'] as $f) {
$body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n";
@@ -490,7 +490,7 @@ class commonUrl {
$mail->to = $core->user->email;
$mail->subject = '[' . EMAIL_SUBJECT . '] Nouveaux fichiers uploadés pour ' . $client->prenom . ' ' . $client->nom;
- $body = 'Tous les fichiers de ' . $client->prenom . ' ' . $client->nom . ' : http://extranet.cubedesigners.com/fichiers/' . $client->utilisateur_id . "\n\n";
+ $body = 'Tous les fichiers de ' . $client->prenom . ' ' . $client->nom . ' : http://'.$_SERVER['HTTP_HOST'].'/fichiers/' . $client->utilisateur_id . "\n\n";
$body .= 'Fichiers chargés : ' . "\n";
foreach($_SESSION['files_uploaded'] as $f) {
$body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n";
@@ -534,6 +534,45 @@ class commonUrl {
$dao = new extranetDAOFichier($core->con);
$dao->deleteOldFiles();
}
+
+ public static function adresse($utilisateur_id = null, $projet_id = null, $display = 'devis', $adresse = '')
+ {
+ global $core;
+ $dao = new commonDAOClient($core->con);
+ if (!is_null($utilisateur_id)) {
+ $client = $dao->selectById($utilisateur_id);
+ }
+ if (!is_null($projet_id)) {
+ $client = $dao->selectByProjet($projet_id);
+ }
+ if (is_null($client)) {
+ return false;
+ }
+
+ if ($adresse == '') {
+ $adresse = array();
+ fb($client->adresse_facturation);
+ if ($client->adresse_facturation != '') {
+ $adresse[] = $client->adresse_facturation;
+ } else {
+ $adresse[] = $client->rs;
+ $adresse[] = trim($client->adresse);
+ $adresse[] = $client->code_postal . ' ' . $client->ville;
+ $adresse[] = cubeCountry::getCountry($client->pays);
+ }
+ } else {
+ $adresse = explode("\n", trim($adresse));
+ }
+ if ($display == 'facture' && $client->tva_intra != '' && cubeCountry::inUE($client->pays)) {
+ $tva = '
' . __('N° de TVA Intracommunautaire') . ' : ' . $client->tva_intra . '';
+ } else {
+ $tva = '';
+ }
+ $a = form::textarea('adresse', 40, 6, implode("\n", $adresse));
+ $a .= $tva;
+ $a .= '';
+ return $a;
+ }
}
?>
\ No newline at end of file
diff --git a/inc/extranet/Controlleur/class.extranet.url.php b/inc/extranet/Controlleur/class.extranet.url.php
index 1d93a8c85..caa74076b 100644
--- a/inc/extranet/Controlleur/class.extranet.url.php
+++ b/inc/extranet/Controlleur/class.extranet.url.php
@@ -1044,45 +1044,6 @@ class extranetUrl {
return $res;
}
- public static function adresse($utilisateur_id = null, $projet_id = null, $display = 'devis', $adresse = '')
- {
- global $core;
- $dao = new commonDAOClient($core->con);
- if (!is_null($utilisateur_id)) {
- $client = $dao->selectById($utilisateur_id);
- }
- if (!is_null($projet_id)) {
- $client = $dao->selectByProjet($projet_id);
- }
- if (is_null($client)) {
- return false;
- }
-
- if ($adresse == '') {
- $adresse = array();
- fb($client->adresse_facturation);
- if ($client->adresse_facturation != '') {
- $adresse[] = $client->adresse_facturation;
- } else {
- $adresse[] = $client->rs;
- $adresse[] = trim($client->adresse);
- $adresse[] = $client->code_postal . ' ' . $client->ville;
- $adresse[] = cubeCountry::getCountry($client->pays);
- }
- } else {
- $adresse = explode("\n", trim($adresse));
- }
- if ($display == 'facture' && $client->tva_intra != '' && cubeCountry::inUE($client->pays)) {
- $tva = '
' . __('N° de TVA Intracommunautaire') . ' : ' . $client->tva_intra . '';
- } else {
- $tva = '';
- }
- $a = form::textarea('adresse', 40, 6, implode("\n", $adresse));
- $a .= $tva;
- $a .= '';
- return $a;
- }
-
public static function previewDevis($args)
{
global $core;
diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php
index 7040ca7d0..6e3a1dabf 100644
--- a/inc/ws/Controlleur/class.ws.ajax.php
+++ b/inc/ws/Controlleur/class.ws.ajax.php
@@ -1,6 +1,114 @@
' . wsUrl::listeContacts($args[1]) . '
';
+ }
+ $extra .= '
' . $core->typo->BoutonOK(__('Enregistrer')) . '
';
+
+ commonAjax::form('saveClient', __("Edition d'un client"), wsUrl::formClient($args[1]), false, 2, '', $extra);
+ }
+
+ public static function formContact($args, &$x)
+ {
+ if (!isset($args[2])) {
+ $args[2] = null;
+ }
+ commonAjax::form('saveContact', __("Edition d'un contact"), wsUrl::formContact($args[1], $args[2]));
+ }
+
+ public static function saveClient($args, &$x)
+ {
+ global $core;
+ $dao = new commonDAOEntreprise($core->con);
+ $entreprise = $dao->sauve($_POST);
+ if ($_POST['entreprise_id'] == 'new') {
+ $data = $_POST['contact'];
+ $data['entreprise'] = $entreprise->entreprise_id;
+ $data['utilisateur_id'] = 'new';
+ $data['adresse'] = $entreprise->adresse;
+ $data['code_postal'] = $entreprise->code_postal;
+ $data['ville'] = $entreprise->ville;
+ $data['pays'] = $entreprise->pays;
+ $data['grade'] = 0;
+ $data['adresse_facturation'] = $entreprise->adresse_facturation;
+ $daoClient = new commonDAOClient($core->con);
+ try {
+ $daoClient->sauve($data);
+ }
+ catch(exception $e) {
+ $dao->supprime($entreprise->entreprise_id);
+ }
+ }
+
+ $x->addContent('listeClients', wsUrl::listeClients());
+ $x->addClosePopup();
+ }
+
+ public static function saveNotes($args, &$x)
+ {
+ global $core;
+ $dao = new commonDAOClient($core->con);
+ $dao->sauveNotes($_POST['utilisateur_id'], $_POST['notes']);
+ $x->addClosePopup();
+ }
+
+ public static function saveContact($args, &$x)
+ {
+ global $core;
+ $dao = new commonDAOClient($core->con);
+ $client = $dao->sauve($_POST);
+ $x->addClosePopup();
+ $x->addContent('devisAdresseDisplay', wsUrl::adresse($client->utilisateur_id, null, 'devis'));
+ $x->addContent('factureAdresseDisplay', wsUrl::adresse($client->utilisateur_id, null, 'facture'));
+ $x->addContent('listeContacts', wsUrl::listeContacts($client->entreprise));
+ $contacts = array();
+ $client_contacts = $dao->getContactsOfEntreprise($client->entreprise);
+ foreach($client_contacts as $c) {
+ $contacts[] = '';
+ }
+ $x->addContent('contacts_' . $client->entreprise, implode(', ', $contacts));
+
+ $x->addPopupDimensions();
+ }
+
+ public static function supprimeClient($args, &$x)
+ {
+ global $core;
+ $dao = new commonDAOEntreprise($core->con);
+ $dao->supprime($args[1]);
+
+ $x->addContent('listeClients', wsUrl::listeClients());
+ }
+
+ public static function searchClients($args, &$x)
+ {
+ $x->addContent('listeClients', wsUrl::listeClients());
+ }
+
+ public static function sortClient($args, &$x)
+ {
+ commonAjax::sort('clients', $args[1]);
+ $x->addContent('listeClients', wsUrl::listeClients());
+ }
+
+ public static function pageClient($args, &$x)
+ {
+ commonAjax::page('clients', $args[1]);
+ $x->addContent('listeClients', wsUrl::listeClients());
+ }
+
+ public static function parPageClient($args, &$x)
+ {
+ commonAjax::parPage('clients', $_POST['par_page']);
+ $x->addContent('listeClients', wsUrl::listeClients());
+ }
+
public static function supprimeBook($args, &$x)
{
global $core;
--
2.39.5