From d6fbc2140ed26540d8b3e37b7b12512062f459c7 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 9 Nov 2021 12:11:06 +0000 Subject: [PATCH] wip #4867 @1 --- inc/commons/DAO/class.common.dao.client.php | 5 +- .../DAO/class.common.dao.utilisateur.php | 7 +- .../Controlleur/class.extranet.ajax.php | 1212 +++++++++-------- inc/ws/DAO/class.ws.dao.theme.php | 3 - inc/ws/Metier/class.ws.theme.parametres.php | 2 +- .../html5/master/class.ws.html5.compiler.php | 6 +- 6 files changed, 650 insertions(+), 585 deletions(-) diff --git a/inc/commons/DAO/class.common.dao.client.php b/inc/commons/DAO/class.common.dao.client.php index 1cf060a9f..75b459e46 100644 --- a/inc/commons/DAO/class.common.dao.client.php +++ b/inc/commons/DAO/class.common.dao.client.php @@ -38,7 +38,6 @@ class commonDAOClient extends commonDAOUtilisateur { public function getListe($orderby = null, $sens = null, $limit = null, $where = null, $limitedToUserRights = false) { $sql = $this->getQueryList('clients', $orderby, $sens, $limit, $where,$limitedToUserRights); - fb($sql); $r = $this->con->select($sql); return $this->factory($r); } @@ -104,6 +103,4 @@ class commonDAOClient extends commonDAOUtilisateur { $r = $this->con->select('SELECT * FROM clients WHERE entreprise IN(' . implode(',', $entreprises_ids) . ')'); return $this->factory($r); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/inc/commons/DAO/class.common.dao.utilisateur.php b/inc/commons/DAO/class.common.dao.utilisateur.php index e690b849a..f828ebb8e 100644 --- a/inc/commons/DAO/class.common.dao.utilisateur.php +++ b/inc/commons/DAO/class.common.dao.utilisateur.php @@ -93,7 +93,7 @@ class commonDAOUtilisateur extends commonDAO $utilisateur->prenom = ''; $utilisateur->email = ''; $utilisateur->password = crypt::createPassword(); - $utilisateur->api_token= CubeIT_Crypt::generateRandomString(60); + $utilisateur->api_token = CubeIT_Crypt::generateRandomString(60); $utilisateur->adresse = ''; $utilisateur->code_postal = ''; $utilisateur->ville = ''; @@ -249,16 +249,18 @@ class commonDAOUtilisateur extends commonDAO $c->e1_mobile = $data['mobile']; $c->locale = $data['lang']; $c->company = $data['entreprise']; + $c->created_ok = 1; if ($data['grade'] > 0) { $c->agence = $data['agence']; } + try { // Nouveau client if ($data['utilisateur_id'] == 'new') { $c->id = $this->getNextId(); $c->insert(); $core->refreshWSUsersTree(); - return $this->selectById($c->utilisateur_id); + return $this->selectById($c->id); } else { // Mise à jour d'un client $c->update('WHERE id=\'' . $this->con->escape($data['utilisateur_id']) . '\''); @@ -267,6 +269,7 @@ class commonDAOUtilisateur extends commonDAO } } catch (Exception $e) { echo $e->getMessage(); + exit; } } diff --git a/inc/extranet/Controlleur/class.extranet.ajax.php b/inc/extranet/Controlleur/class.extranet.ajax.php index d8a62c79a..196e2cae5 100644 --- a/inc/extranet/Controlleur/class.extranet.ajax.php +++ b/inc/extranet/Controlleur/class.extranet.ajax.php @@ -1,577 +1,645 @@


' . extranetUrl::listeContacts($args[1]) . '
'; - } - $extra .= '



' . $core->typo->BoutonOK(__('Enregistrer')) . '

'; - - commonAjax::form('saveClient', __("Edition d'un client"), extranetUrl::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"), extranetUrl::formContact($args[1], $args[2])); - } - - public static function formNotes($args, &$x) { - global $core; - commonAjax::form('saveNotes', __('Edition des notes'), extranetUrl::formNotes($args[1])); - } - - 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) { - } - } - - $x->addContent('listeClients', extranetUrl::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', commonUrl::adresse($client->utilisateur_id, null, 'devis')); - $x->addContent('factureAdresseDisplay', commonUrl::adresse($client->utilisateur_id, null, 'facture')); - $x->addContent('listeContacts', extranetUrl::listeContacts($client->entreprise)); - $contacts = array(); - $client_contacts = $dao->getContactsOfEntreprise($client->entreprise); - foreach ($client_contacts as $c) { - $contacts[] = '' . $c->prenom . ' ' . $c->nom . ''; - } - $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', extranetUrl::listeClients()); - } - - public static function searchClients($args, &$x) { - $x->addContent('listeClients', extranetUrl::listeClients()); - } - - public static function sortClient($args, &$x) { - commonAjax::sort('clients', $args[1]); - $x->addContent('listeClients', extranetUrl::listeClients()); - } - - public static function sortEquipier($args, &$x) { - commonAjax::sort('equipiers', $args[1]); - $x->addContent('listeEquipiers', extranetUrl::listeRh()); - } - - public static function pageClient($args, &$x) { - commonAjax::page('clients', $args[1]); - $x->addContent('listeClients', extranetUrl::listeClients()); - } - - public static function parPageClient($args, &$x) { - commonAjax::parPage('clients', $_POST['par_page']); - $x->addContent('listeClients', extranetUrl::listeClients()); - } - - public static function filtreClients($args, &$x) { - if (isset($args[1]) && $args[1] == 'efface') { - commonAjax::filtre('clients'); - $x->addReload(); - return; - } else { - commonAjax::filtre('clients', $_POST); - $x->addContent('listeClients', extranetUrl::listeClients()); - } - } - - public static function clientDetailCa($args, &$x) { - global $core; - $dao = new commonDAOEntreprise($core->con); - $client = $dao->selectById($args[1]); - return commonAjax::form('', __("Détail du chiffre d'affaire de") . ' ' . $client->nom, extranetUrl::clientDetailCa($args[1]), false); - } - - public static function clientDetailImpaye($args, &$x) { - global $core; - $dao = new commonDAOEntreprise($core->con); - $client = $dao->selectById($args[1]); - return commonAjax::form('', __("Détail des impayés de") . ' ' . $client->nom, extranetUrl::clientDetailImpaye($args[1]), false, 4); - } - - public static function formProjet($args, &$x) { - commonAjax::form('saveProjet', __("Edition d'un projet"), extranetUrl::formProjet($args[1])); - } - - public static function saveProjet($args, &$x) { - global $core; - - $error = false; - if ($_POST['client'] == '') { - $x->addError('client'); - $error = true; - } else { - $x->addOk('client'); - } - - if ($error) { - return; - } - - $dao = new extranetDAOProjet($core->con); - $id = $dao->sauve($_POST); - - $x->addContent('listeProjets', extranetUrl::listeProjets()); - $x->addRedirection(SITE_PATH . 'projet/' . $id); - } - - public static function changeProjetStatus($args, &$x) { - global $core; - $dao = new extranetDAOProjet($core->con); - $dao->changeStatus($args[1]); - - $x->addContent('listeProjet', extranetUrl::listeProjet($args[1])); - } - - public static function changeProjetsStatus($args, &$x) { - global $core; - $dao = new extranetDAOProjet($core->con); - $dao->changeStatus($args[1]); - - $x->addContent('listeProjets', extranetUrl::listeProjets($args[1])); - } - - public static function supprimeProjet($args, &$x) { - global $core; - $dao = new extranetDAOProjet($core->con); - $dao->supprime($args[1]); - - $x->addRedirection(SITE_PATH . 'projets'); - } - - public static function searchProjets($args, &$x) { - $x->addContent('listeProjets', extranetUrl::listeProjets()); - } - - public static function pageProjet($args, &$x) { - commonAjax::page('projets', $args[1]); - $x->addContent('listeProjets', extranetUrl::listeProjets()); - } - - public static function parPageProjet($args, &$x) { - commonAjax::parPage('projets', $_POST['par_page']); - $x->addContent('listeProjets', extranetUrl::listeProjets()); - } - - public static function sortProjet($args, &$x) { - commonAjax::sort('projets', $args[1]); - $x->addContent('listeProjets', extranetUrl::listeProjets()); - } - - public static function filtreProjet($args, &$x) { - if (isset($args[1]) && $args[1] == 'efface') { - commonAjax::filtre('projets'); - $x->addReload(); - return; - } else { - commonAjax::filtre('projets', $_POST); - $x->addContent('listeProjets', extranetUrl::listeProjets()); - } - } - - public static function formTacheNormale($args, &$x) { - $projet = isset($args[2]) ? $args[2] : null; - commonAjax::form('saveTache', __("Edition d'un tâche"), extranetUrl::formTacheNormale($args[1], $projet)); - } - - public static function formTacheSousTraitee($args, &$x) { - $projet = isset($args[2]) ? $args[2] : null; - commonAjax::form('saveTache', __("Edition d'un tâche sous-traitée"), extranetUrl::formTacheSousTraitee($args[1], $projet)); - } - - public static function saveTache($args, &$x) { - global $core; - $dao = new extranetDAOTache($core->con); - $dao->sauve($_POST); - - $x->addContent('listeProjet', extranetUrl::listeProjet($_POST['projet'])); - $x->addClosePopup(); - } - - public static function supprimeTache($args, &$x) { - global $core; - $dao = new extranetDAOTache($core->con); - $tache = $dao->selectById($args[1]); - - $dao->supprime($args[1]); - $x->addContent('listeProjet', extranetUrl::listeProjet($tache->projet)); - } - - public static function saveTimereport($args, &$x) { - global $core; - $date = $args[1]; - $heures = $args[3]; - $tache_id = $args[2]; - $dao = new extranetDAOTimereport($core->con); - - $x->addValue('t_' . $date . '_' . $tache_id, $dao->sauve($core->user->utilisateur_id, $tache_id, $date, $heures)); - // Mise a jour des valeurs pour le projet et la tâche - $daoProjet = new extranetDAOProjet($core->con); - $projet = $daoProjet->getProjetByTache($tache_id); - foreach ($projet as $p) { - $p->progression = !$p->progression ? '-' : $p->progression . '%'; - $p->jours_consommes = !$p->jours_consommes ? '-' : $p->jours_consommes; - foreach ($p->taches as $t) { - if ($t->tache_id != $tache_id) { - continue; - } - $t->progression = !$t->progression ? '-' : $t->progression . '%'; - $t->jours_consommes = !$t->jours_consommes ? '-' : $t->jours_consommes; - break; - } - $x->addContent('progress_projet_' . $p->projet_id, $p->progression); - $x->addContent('consommees_projet_' . $p->projet_id, $p->jours_consommes); - $x->addContent('progress_' . $tache_id, $t->progression); - $x->addContent('consommees_' . $tache_id, $t->jours_consommes); - } - } - - public static function sortTimereport($args, &$x) { - commonAjax::sort('timereport', $args[1]); - $x->addContent('listeTimereport', extranetUrl::listeTimereport()); - } - - public static function pageTimereport($args, &$x) { - commonAjax::page('timereport', $args[1]); - $x->addContent('listeTimereport', extranetUrl::listeTimereport()); - } - - public static function searchTimereport($args, &$x) { - $x->addContent('listeTimereport', extranetUrl::listeTimereport()); - } - - public static function parPageTimereport($args, &$x) { - commonAjax::parPage('timereport', $_POST['par_page']); - $x->addContent('listeTimereport', extranetUrl::listeTimereport()); - } - - public static function filtreTimereport($args, &$x) { - if (isset($args[1]) && $args[1] == 'efface') { - commonAjax::filtre('timereport'); - $x->addReload(); - return; - } else { - commonAjax::filtre('timereport', $_POST); - $x->addContent('listeTimereport', extranetUrl::listeTimereport()); - } - } - - public static function changeDevisStatus($args, &$x) { - global $core; - $dao = new extranetDAODevis($core->con); - $dao->changeStatus($args[1], $args[2]); - - if (isset($args[3]) && $args[3] == 'createProjet') { - $daoProjet = new extranetDAOProjet($core->con); - $projet_id = $daoProjet->createFromDevis($args[1], $core->user->utilisateur_id); - $x->addRedirection(SITE_PATH . 'projet/' . $projet_id); - } else { - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - } - - public static function supprimeDevis($args, &$x) { - global $core; - $dao = new extranetDAODevis($core->con); - $dao->supprime($args[1]); - @unlink(ROOT . '/docs/devis/' . $args[1] . '.pdf'); - - $x->addContent('listeDevis', extranetUrl::listeDevis()); - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - - public static function searchDevis($args, &$x) { - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - - public static function pageDevis($args, &$x) { - commonAjax::page('devis', $args[1]); - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - - public static function parPageDevis($args, &$x) { - commonAjax::parPage('devis', $_POST['par_page']); - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - - public static function sortDevis($args, &$x) { - commonAjax::sort('devis', $args[1]); - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - - public static function filtreDevis($args, &$x) { - if (isset($args[1]) && $args[1] == 'efface') { - commonAjax::filtre('devis'); - $x->addReload(); - return; - } else { - commonAjax::filtre('devis', $_POST); - $x->addContent('listeDevis', extranetUrl::listeDevis()); - } - } - - public static function sortDevisClient($args, &$x) { - commonAjax::sort('devis', $args[1]); - $x->addContent('listeDevis', extranetUrl::listeDevisClient()); - } - - public static function expedieDevis($args, &$x) { - global $core; - $dao = new extranetDAODevis($core->con); - $devis = $dao->selectByID($args[2]); - - $daoUtilisateur = new commonDAOUtilisateur($core->con); - $devis->client = $daoUtilisateur->selectById($devis->client_id); - $devis->createur = $daoUtilisateur->selectById($devis->createur_id); - - if ($args[1] == 1) { - // Envoie de l'email - $mail = new cubeMail(); - $mail->from = $devis->createur->getEmail(); - $mail->bcc = MAIL_BCC; - $mail->bcc = $devis->createur->getEmail(); - $mail->to = $devis->client->getEmail(); - $mail->subject = $devis->email['sujet']; - $mail->body = $devis->email['corps'] . "\r\n\r\n" . $devis->createur->getSignature(); - $mail->addFile('Devis.pdf', ROOT . '/docs/devis/' . $devis->devis_id . '.pdf'); - $mail->send(); - } - // On marque le devis comme envoyé - $dao->changeStatus($devis->devis_id, 1); - $x->addDownloadFile('/voirdevis/' . $devis->devis_id . '/1'); - $x->addRedirection(SITE_PATH . 'devis'); - } - - public static function duplicateDevis($args, &$x) { - global $core; - $dao = new extranetDAODevis($core->con); - $devis = $dao->duplique($args[1], $core->user->utilisateur_id); - $x->addRedirection(SITE_PATH . 'editedevis/' . $devis->devis_id); - } - - public static function changeFactureStatus($args, &$x) { - global $core; - $dao = new extranetDAOFacture($core->con); - $dao->changeStatus($args[1], $args[2]); - - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function changeFacturePaiement($args, &$x) { - return commonAjax::form('saveFacturePaiement', __('Informations relatives au paiement de la facture'), extranetUrl::formFacturePaiement($args[1])); - } - - public static function saveFacturePaiement($args, &$x) { - global $core; - $dao = new extranetDAOFacture($core->con); - $dao->savePaiement($_POST); - $x->addClosePopup(); - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function supprimeFacture($args, &$x) { - global $core; - $dao = new extranetDAOFacture($core->con); - $dao->supprime($args[1]); - @unlink(ROOT . '/docs/facture/' . $args[1] . '.pdf'); - - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function valideFacture($args, &$x) { - global $core; - $dao = new extranetDAOFacture($core->con); - $id = $dao->valide($args[1]); - - $x->addTruePopup('/voirfacture/' . $id); - $x->addRedirection(SITE_PATH . 'factures'); - } - - public static function searchFactures($args, &$x) { - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function pageFacture($args, &$x) { - commonAjax::page('factures', $args[1]); - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function parPageFacture($args, &$x) { - commonAjax::parPage('factures', $_POST['par_page']); - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function sortFacture($args, &$x) { - commonAjax::sort('factures', $args[1]); - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - - public static function filtreFactures($args, &$x) { - if (isset($args[1]) && $args[1] == 'efface') { - commonAjax::filtre('factures'); - $x->addReload(); - return; - } else { - commonAjax::filtre('factures', $_POST); - $x->addContent('listeFactures', extranetUrl::listeFactures()); - } - } - - public static function sauveFactures($args, &$x) { - global $core; - $dao = new extranetDAOFacture($core->con); - $dao->sauve($_POST); - - $x->addRedirection(SITE_PATH . 'factures'); - } - - public static function duplicateFacture($args, &$x) { - global $core; - - $dao = new extranetDAOFacture($core->con); - $facture = $dao->duplique($args[1], $core->user->utilisateur_id); - - $x->addRedirection(SITE_PATH . 'editefacture/' . $facture->facture_id); - } - - public static function formPrintFactures($args, &$x) { - commonAjax::form('printFactures', __('Imprimer des factures'), extranetUrl::formPrintFactures(), __("Lancer l'impression")); - } - - public static function printFactures($args, &$x) { - global $core; - $factures = cubeArray::parseRange($_POST['factures']); - - $liste = array(); - foreach ($factures as $f) { - if (file_exists(ROOT . '/docs/factures/' . $f . '.pdf')) { - $liste[] = ROOT . '/docs/factures/' . $f . '.pdf'; - } - } - $liste[] = 'output'; - $liste[] = ROOT . '/docs/factures/print_' . $core->user->utilisateur_id . '_' . TIME . '.pdf'; - - $pdftk = new cubeCommandLine('pdftk'); - $pdftk->setManualArg(implode(' ', $liste)); - $pdftk->execute(); - - $core->user->saveLastPrint($_POST['factures']); - - $x->addClosePopup(); - $x->addTruePopup(SITE_PATH . 'voirfacture/print_' . $core->user->utilisateur_id . '_' . TIME); - $core->sauvePreferencesUtilisateur(); - } - - public static function getAdresseForDevis($args, &$x) { - $adresse = commonUrl::adresse($args[1], null, 'devis'); - if (!$adresse) { - $x->addError('client_nom', ''); - } else { - $x->addContent('devisAdresseDisplay', $adresse); - } - } - - public static function getAdresseForFacture($args, &$x) { - $adresse = commonUrl::adresse(null, $args[1], 'facture'); - if (!$adresse) { - $x->addError('projet_nom', ''); - } else { - $x->addContent('factureAdresseDisplay', $adresse); - } - } - - public static function saveTrad($args, &$x) { - $data = cubeLang::dataToFile($_POST); - file_put_contents(L10N . '/en/main.lang.php', $data); - $x->addAlert(__('Traductions sauvegardées')); - } - - public static function previewDevis($args, &$x) { - global $core; - - $daoUtilisateur = new commonDAOUtilisateur($core->con); - if (is_null($daoUtilisateur->selectById($_POST['client']))) { - $x->addError('client_nom'); - $x->addRedirection('#'); - return; - } - - commonDroits::min(1); - $dao = new extranetDAODevis($core->con); - $devis = $dao->sauve($core->user->utilisateur_id, $_POST); - $dao->saveAsPdf($devis->devis_id); - $x->addRedirection(SITE_PATH . 'previewDevis/' . $devis->devis_id); - } - - public static function previewFacture($args, &$x) { - global $core; - commonDroits::min(1); - - $daoProjet = new extranetDAOProjet($core->con); - $daoClient = new commonDAOClient($core->con); - if (is_null($daoProjet->selectById($_POST['projet'])) && (!isset($_POST['client']) || is_null($daoClient->selectById($_POST['client'])))) { - $x->addError('projet_nom'); - $x->addRedirection('#'); - return; - } - - $dao = new extranetDAOFacture($core->con); - $facture = $dao->sauve($_POST, $core->user->utilisateur_id); - $dao->saveAsPdf($facture->facture_id); - $x->addRedirection(SITE_PATH . 'previewFacture/' . $facture->facture_id); - } - - public static function chargesDetails($args, &$x) { - commonAjax::form('', sprintf(__("Détails des charges de l'année %s"), date('Y')), extranetPageChiffres::chargesDetails($args), '', 3, 'liste'); - } - - public static function makeFavicon($args, &$x) { - $x->addRedirection(extranetTools::makeFavicon()); - } +class extranetAjax +{ + + public static function formClient($args, &$x) + { + global $core; + if ($args[1] == 'new') { + $extra = ''; + } else { + $extra = '




' . extranetUrl::listeContacts($args[1]) . '
'; + } + $extra .= '



' . $core->typo->BoutonOK(__('Enregistrer')) . '

'; + + commonAjax::form('saveClient', __("Edition d'un client"), extranetUrl::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"), extranetUrl::formContact($args[1], $args[2])); + } + + public static function formNotes($args, &$x) + { + global $core; + commonAjax::form('saveNotes', __('Edition des notes'), extranetUrl::formNotes($args[1])); + } + + 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) { + } + } + + $x->addContent('listeClients', extranetUrl::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->addDebug(print_r($client)); + $x->addClosePopup(); + $x->addContent('devisAdresseDisplay', commonUrl::adresse($client->utilisateur_id, null, 'devis')); + $x->addContent('factureAdresseDisplay', commonUrl::adresse($client->utilisateur_id, null, 'facture')); + $x->addContent('listeContacts', extranetUrl::listeContacts($client->entreprise)); + $contacts = array(); + $client_contacts = $dao->getContactsOfEntreprise($client->entreprise); + foreach ($client_contacts as $c) { + $contacts[] = '' . $c->prenom . ' ' . $c->nom . ''; + } + $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', extranetUrl::listeClients()); + } + + public static function searchClients($args, &$x) + { + $x->addContent('listeClients', extranetUrl::listeClients()); + } + + public static function sortClient($args, &$x) + { + commonAjax::sort('clients', $args[1]); + $x->addContent('listeClients', extranetUrl::listeClients()); + } + + public static function sortEquipier($args, &$x) + { + commonAjax::sort('equipiers', $args[1]); + $x->addContent('listeEquipiers', extranetUrl::listeRh()); + } + + public static function pageClient($args, &$x) + { + commonAjax::page('clients', $args[1]); + $x->addContent('listeClients', extranetUrl::listeClients()); + } + + public static function parPageClient($args, &$x) + { + commonAjax::parPage('clients', $_POST['par_page']); + $x->addContent('listeClients', extranetUrl::listeClients()); + } + + public static function filtreClients($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('clients'); + $x->addReload(); + return; + } else { + commonAjax::filtre('clients', $_POST); + $x->addContent('listeClients', extranetUrl::listeClients()); + } + } + + public static function clientDetailCa($args, &$x) + { + global $core; + $dao = new commonDAOEntreprise($core->con); + $client = $dao->selectById($args[1]); + return commonAjax::form('', __("Détail du chiffre d'affaire de") . ' ' . $client->nom, extranetUrl::clientDetailCa($args[1]), false); + } + + public static function clientDetailImpaye($args, &$x) + { + global $core; + $dao = new commonDAOEntreprise($core->con); + $client = $dao->selectById($args[1]); + return commonAjax::form('', __("Détail des impayés de") . ' ' . $client->nom, extranetUrl::clientDetailImpaye($args[1]), false, 4); + } + + public static function formProjet($args, &$x) + { + commonAjax::form('saveProjet', __("Edition d'un projet"), extranetUrl::formProjet($args[1])); + } + + public static function saveProjet($args, &$x) + { + global $core; + + $error = false; + if ($_POST['client'] == '') { + $x->addError('client'); + $error = true; + } else { + $x->addOk('client'); + } + + if ($error) { + return; + } + + $dao = new extranetDAOProjet($core->con); + $id = $dao->sauve($_POST); + + $x->addContent('listeProjets', extranetUrl::listeProjets()); + $x->addRedirection(SITE_PATH . 'projet/' . $id); + } + + public static function changeProjetStatus($args, &$x) + { + global $core; + $dao = new extranetDAOProjet($core->con); + $dao->changeStatus($args[1]); + + $x->addContent('listeProjet', extranetUrl::listeProjet($args[1])); + } + + public static function changeProjetsStatus($args, &$x) + { + global $core; + $dao = new extranetDAOProjet($core->con); + $dao->changeStatus($args[1]); + + $x->addContent('listeProjets', extranetUrl::listeProjets($args[1])); + } + + public static function supprimeProjet($args, &$x) + { + global $core; + $dao = new extranetDAOProjet($core->con); + $dao->supprime($args[1]); + + $x->addRedirection(SITE_PATH . 'projets'); + } + + public static function searchProjets($args, &$x) + { + $x->addContent('listeProjets', extranetUrl::listeProjets()); + } + + public static function pageProjet($args, &$x) + { + commonAjax::page('projets', $args[1]); + $x->addContent('listeProjets', extranetUrl::listeProjets()); + } + + public static function parPageProjet($args, &$x) + { + commonAjax::parPage('projets', $_POST['par_page']); + $x->addContent('listeProjets', extranetUrl::listeProjets()); + } + + public static function sortProjet($args, &$x) + { + commonAjax::sort('projets', $args[1]); + $x->addContent('listeProjets', extranetUrl::listeProjets()); + } + + public static function filtreProjet($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('projets'); + $x->addReload(); + return; + } else { + commonAjax::filtre('projets', $_POST); + $x->addContent('listeProjets', extranetUrl::listeProjets()); + } + } + + public static function formTacheNormale($args, &$x) + { + $projet = isset($args[2]) ? $args[2] : null; + commonAjax::form('saveTache', __("Edition d'un tâche"), extranetUrl::formTacheNormale($args[1], $projet)); + } + + public static function formTacheSousTraitee($args, &$x) + { + $projet = isset($args[2]) ? $args[2] : null; + commonAjax::form('saveTache', __("Edition d'un tâche sous-traitée"), extranetUrl::formTacheSousTraitee($args[1], $projet)); + } + + public static function saveTache($args, &$x) + { + global $core; + $dao = new extranetDAOTache($core->con); + $dao->sauve($_POST); + + $x->addContent('listeProjet', extranetUrl::listeProjet($_POST['projet'])); + $x->addClosePopup(); + } + + public static function supprimeTache($args, &$x) + { + global $core; + $dao = new extranetDAOTache($core->con); + $tache = $dao->selectById($args[1]); + + $dao->supprime($args[1]); + $x->addContent('listeProjet', extranetUrl::listeProjet($tache->projet)); + } + + public static function saveTimereport($args, &$x) + { + global $core; + $date = $args[1]; + $heures = $args[3]; + $tache_id = $args[2]; + $dao = new extranetDAOTimereport($core->con); + + $x->addValue('t_' . $date . '_' . $tache_id, $dao->sauve($core->user->utilisateur_id, $tache_id, $date, $heures)); + // Mise a jour des valeurs pour le projet et la tâche + $daoProjet = new extranetDAOProjet($core->con); + $projet = $daoProjet->getProjetByTache($tache_id); + foreach ($projet as $p) { + $p->progression = !$p->progression ? '-' : $p->progression . '%'; + $p->jours_consommes = !$p->jours_consommes ? '-' : $p->jours_consommes; + foreach ($p->taches as $t) { + if ($t->tache_id != $tache_id) { + continue; + } + $t->progression = !$t->progression ? '-' : $t->progression . '%'; + $t->jours_consommes = !$t->jours_consommes ? '-' : $t->jours_consommes; + break; + } + $x->addContent('progress_projet_' . $p->projet_id, $p->progression); + $x->addContent('consommees_projet_' . $p->projet_id, $p->jours_consommes); + $x->addContent('progress_' . $tache_id, $t->progression); + $x->addContent('consommees_' . $tache_id, $t->jours_consommes); + } + } + + public static function sortTimereport($args, &$x) + { + commonAjax::sort('timereport', $args[1]); + $x->addContent('listeTimereport', extranetUrl::listeTimereport()); + } + + public static function pageTimereport($args, &$x) + { + commonAjax::page('timereport', $args[1]); + $x->addContent('listeTimereport', extranetUrl::listeTimereport()); + } + + public static function searchTimereport($args, &$x) + { + $x->addContent('listeTimereport', extranetUrl::listeTimereport()); + } + + public static function parPageTimereport($args, &$x) + { + commonAjax::parPage('timereport', $_POST['par_page']); + $x->addContent('listeTimereport', extranetUrl::listeTimereport()); + } + + public static function filtreTimereport($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('timereport'); + $x->addReload(); + return; + } else { + commonAjax::filtre('timereport', $_POST); + $x->addContent('listeTimereport', extranetUrl::listeTimereport()); + } + } + + public static function changeDevisStatus($args, &$x) + { + global $core; + $dao = new extranetDAODevis($core->con); + $dao->changeStatus($args[1], $args[2]); + + if (isset($args[3]) && $args[3] == 'createProjet') { + $daoProjet = new extranetDAOProjet($core->con); + $projet_id = $daoProjet->createFromDevis($args[1], $core->user->utilisateur_id); + $x->addRedirection(SITE_PATH . 'projet/' . $projet_id); + } else { + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + } + + public static function supprimeDevis($args, &$x) + { + global $core; + $dao = new extranetDAODevis($core->con); + $dao->supprime($args[1]); + @unlink(ROOT . '/docs/devis/' . $args[1] . '.pdf'); + + $x->addContent('listeDevis', extranetUrl::listeDevis()); + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + + public static function searchDevis($args, &$x) + { + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + + public static function pageDevis($args, &$x) + { + commonAjax::page('devis', $args[1]); + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + + public static function parPageDevis($args, &$x) + { + commonAjax::parPage('devis', $_POST['par_page']); + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + + public static function sortDevis($args, &$x) + { + commonAjax::sort('devis', $args[1]); + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + + public static function filtreDevis($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('devis'); + $x->addReload(); + return; + } else { + commonAjax::filtre('devis', $_POST); + $x->addContent('listeDevis', extranetUrl::listeDevis()); + } + } + + public static function sortDevisClient($args, &$x) + { + commonAjax::sort('devis', $args[1]); + $x->addContent('listeDevis', extranetUrl::listeDevisClient()); + } + + public static function expedieDevis($args, &$x) + { + global $core; + $dao = new extranetDAODevis($core->con); + $devis = $dao->selectByID($args[2]); + + $daoUtilisateur = new commonDAOUtilisateur($core->con); + $devis->client = $daoUtilisateur->selectById($devis->client_id); + $devis->createur = $daoUtilisateur->selectById($devis->createur_id); + + if ($args[1] == 1) { + // Envoie de l'email + $mail = new cubeMail(); + $mail->from = $devis->createur->getEmail(); + $mail->bcc = MAIL_BCC; + $mail->bcc = $devis->createur->getEmail(); + $mail->to = $devis->client->getEmail(); + $mail->subject = $devis->email['sujet']; + $mail->body = $devis->email['corps'] . "\r\n\r\n" . $devis->createur->getSignature(); + $mail->addFile('Devis.pdf', ROOT . '/docs/devis/' . $devis->devis_id . '.pdf'); + $mail->send(); + } + // On marque le devis comme envoyé + $dao->changeStatus($devis->devis_id, 1); + $x->addDownloadFile('/voirdevis/' . $devis->devis_id . '/1'); + $x->addRedirection(SITE_PATH . 'devis'); + } + + public static function duplicateDevis($args, &$x) + { + global $core; + $dao = new extranetDAODevis($core->con); + $devis = $dao->duplique($args[1], $core->user->utilisateur_id); + $x->addRedirection(SITE_PATH . 'editedevis/' . $devis->devis_id); + } + + public static function changeFactureStatus($args, &$x) + { + global $core; + $dao = new extranetDAOFacture($core->con); + $dao->changeStatus($args[1], $args[2]); + + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function changeFacturePaiement($args, &$x) + { + return commonAjax::form('saveFacturePaiement', __('Informations relatives au paiement de la facture'), extranetUrl::formFacturePaiement($args[1])); + } + + public static function saveFacturePaiement($args, &$x) + { + global $core; + $dao = new extranetDAOFacture($core->con); + $dao->savePaiement($_POST); + $x->addClosePopup(); + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function supprimeFacture($args, &$x) + { + global $core; + $dao = new extranetDAOFacture($core->con); + $dao->supprime($args[1]); + @unlink(ROOT . '/docs/facture/' . $args[1] . '.pdf'); + + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function valideFacture($args, &$x) + { + global $core; + $dao = new extranetDAOFacture($core->con); + $id = $dao->valide($args[1]); + + $x->addTruePopup('/voirfacture/' . $id); + $x->addRedirection(SITE_PATH . 'factures'); + } + + public static function searchFactures($args, &$x) + { + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function pageFacture($args, &$x) + { + commonAjax::page('factures', $args[1]); + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function parPageFacture($args, &$x) + { + commonAjax::parPage('factures', $_POST['par_page']); + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function sortFacture($args, &$x) + { + commonAjax::sort('factures', $args[1]); + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + + public static function filtreFactures($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + commonAjax::filtre('factures'); + $x->addReload(); + return; + } else { + commonAjax::filtre('factures', $_POST); + $x->addContent('listeFactures', extranetUrl::listeFactures()); + } + } + + public static function sauveFactures($args, &$x) + { + global $core; + $dao = new extranetDAOFacture($core->con); + $dao->sauve($_POST); + + $x->addRedirection(SITE_PATH . 'factures'); + } + + public static function duplicateFacture($args, &$x) + { + global $core; + + $dao = new extranetDAOFacture($core->con); + $facture = $dao->duplique($args[1], $core->user->utilisateur_id); + + $x->addRedirection(SITE_PATH . 'editefacture/' . $facture->facture_id); + } + + public static function formPrintFactures($args, &$x) + { + commonAjax::form('printFactures', __('Imprimer des factures'), extranetUrl::formPrintFactures(), __("Lancer l'impression")); + } + + public static function printFactures($args, &$x) + { + global $core; + $factures = cubeArray::parseRange($_POST['factures']); + + $liste = array(); + foreach ($factures as $f) { + if (file_exists(ROOT . '/docs/factures/' . $f . '.pdf')) { + $liste[] = ROOT . '/docs/factures/' . $f . '.pdf'; + } + } + $liste[] = 'output'; + $liste[] = ROOT . '/docs/factures/print_' . $core->user->utilisateur_id . '_' . TIME . '.pdf'; + + $pdftk = new cubeCommandLine('pdftk'); + $pdftk->setManualArg(implode(' ', $liste)); + $pdftk->execute(); + + $core->user->saveLastPrint($_POST['factures']); + + $x->addClosePopup(); + $x->addTruePopup(SITE_PATH . 'voirfacture/print_' . $core->user->utilisateur_id . '_' . TIME); + $core->sauvePreferencesUtilisateur(); + } + + public static function getAdresseForDevis($args, &$x) + { + $adresse = commonUrl::adresse($args[1], null, 'devis'); + if (!$adresse) { + $x->addError('client_nom', ''); + } else { + $x->addContent('devisAdresseDisplay', $adresse); + } + } + + public static function getAdresseForFacture($args, &$x) + { + $adresse = commonUrl::adresse(null, $args[1], 'facture'); + if (!$adresse) { + $x->addError('projet_nom', ''); + } else { + $x->addContent('factureAdresseDisplay', $adresse); + } + } + + public static function saveTrad($args, &$x) + { + $data = cubeLang::dataToFile($_POST); + file_put_contents(L10N . '/en/main.lang.php', $data); + $x->addAlert(__('Traductions sauvegardées')); + } + + public static function previewDevis($args, &$x) + { + global $core; + + $daoUtilisateur = new commonDAOUtilisateur($core->con); + if (is_null($daoUtilisateur->selectById($_POST['client']))) { + $x->addError('client_nom'); + $x->addRedirection('#'); + return; + } + + commonDroits::min(1); + $dao = new extranetDAODevis($core->con); + $devis = $dao->sauve($core->user->utilisateur_id, $_POST); + $dao->saveAsPdf($devis->devis_id); + $x->addRedirection(SITE_PATH . 'previewDevis/' . $devis->devis_id); + } + + public static function previewFacture($args, &$x) + { + global $core; + commonDroits::min(1); + + $daoProjet = new extranetDAOProjet($core->con); + $daoClient = new commonDAOClient($core->con); + if (is_null($daoProjet->selectById($_POST['projet'])) && (!isset($_POST['client']) || is_null($daoClient->selectById($_POST['client'])))) { + $x->addError('projet_nom'); + $x->addRedirection('#'); + return; + } + + $dao = new extranetDAOFacture($core->con); + $facture = $dao->sauve($_POST, $core->user->utilisateur_id); + $dao->saveAsPdf($facture->facture_id); + $x->addRedirection(SITE_PATH . 'previewFacture/' . $facture->facture_id); + } + + public static function chargesDetails($args, &$x) + { + commonAjax::form('', sprintf(__("Détails des charges de l'année %s"), date('Y')), extranetPageChiffres::chargesDetails($args), '', 3, 'liste'); + } + + public static function makeFavicon($args, &$x) + { + $x->addRedirection(extranetTools::makeFavicon()); + } } diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index b10f61ee9..e7cae3433 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -10,7 +10,6 @@ class wsDAOTheme extends commonDAO $theme->nom = $a['name']; $theme->date = time(); $theme->proprietaire = $a['owner']; - $theme->signature = 0; $theme->icones = 15; $theme->parametres = new wsThemeParametres($theme); $theme->parametres->initFromArray($a); @@ -25,7 +24,6 @@ class wsDAOTheme extends commonDAO $theme->nom = $r->name; $theme->date = strtotime($r->created_at); $theme->proprietaire = $r->owner; - $theme->signature = 0; $theme->icones = 15; $theme->parametres = new wsThemeParametres($theme); $theme->parametres->initFromWS3Data($r); @@ -40,7 +38,6 @@ class wsDAOTheme extends commonDAO if ($r->exists('proprietaire_nom')) { $theme->proprietaire_nom = $r->proprietaire_nom; } - $theme->signature = $r->signature; $theme->icones = $r->icones; if (CubeIT_Util_Json::isJson($r->parametres)) { $p = new wsThemeParametres($theme); diff --git a/inc/ws/Metier/class.ws.theme.parametres.php b/inc/ws/Metier/class.ws.theme.parametres.php index 580050fe8..40ba8d1f9 100644 --- a/inc/ws/Metier/class.ws.theme.parametres.php +++ b/inc/ws/Metier/class.ws.theme.parametres.php @@ -21,7 +21,7 @@ class wsThemeParametres extends wsParametres global $core; $r = $core->con->select('SELECT * FROM `fluidbook_toolbox`.`fluidbook_iconset` WHERE created_ok=1 ORDER BY id'); while ($r->fetch()) { - $iconSets[$r->names] = $r->id; + $iconSets[$r->name] = $r->id; } parent::initFields(); diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 8c7587281..cae1d201c 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -995,7 +995,7 @@ height="0" width="0" style="display:none;visibility:hidden"> if (file_exists($e[0])) { return $path; } - return $this->wdir . $path; + return $this->wdir . $path; } @@ -1010,8 +1010,8 @@ height="0" width="0" style="display:none;visibility:hidden"> } if (preg_match('/^page\/(.+)$/', $k, $matches)) { - $matches[1]=CubeIT_Util_Text::removeAccents($matches[1]); - $matches[1]=mb_strtolower($matches[1]); + $matches[1] = CubeIT_Util_Text::removeAccents($matches[1]); + $matches[1] = mb_strtolower($matches[1]); if (isset($this->pageLabels[$matches[1]])) { return 'page/' . $this->pageLabels[$matches[1]]; } -- 2.39.5