finish filter devis by client group facturation and type, wip export pdf
This commit is contained in:
parent
a267b454c7
commit
28cad12ff0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -348,7 +348,7 @@ class PageController extends Controller {
|
||||
$produits = json_decode($this->myDb->getListProduit($d->id, $this->idNextcloud));
|
||||
$d->dproduits = $produits;
|
||||
}
|
||||
$clients = json_decode($this->myDb->getClients($this->idNextcloud));
|
||||
$clients = json_decode($this->myDb->getClientsAndClientGroupFacturations(includeClientInsideGroup:false));
|
||||
return new TemplateResponse('gestion', 'apercustousdevis', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
|
||||
'configuration'=> $this->getConfiguration(),
|
||||
'devis'=> $devis,
|
||||
|
||||
@ -259,6 +259,7 @@ class Bdd {
|
||||
$sql = "SELECT ".$this->tableprefix."devis.id, ".$this->tableprefix."devis.id as devisid, ".$this->tableprefix."devis.user_id,".$this->tableprefix."devis.id_nextcloud ,".$this->tableprefix."devis.comment ,"
|
||||
.$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, ".$this->tableprefix."client.id as cid, ".$this->tableprefix."client.id as id_client, "
|
||||
.$this->tableprefix."client.adresse as adresse_cli,".$this->tableprefix."client.mail as mail_cli,".$this->tableprefix."client.telephone as telephone_cli,".$this->tableprefix."client.legal_one as legalone_cli,"
|
||||
.$this->tableprefix."client.fk_client_group_facturation_id as fk_client_group_facturation_id,"
|
||||
.$this->tableprefix."thanato.nom as nom_thanato, ".$this->tableprefix."thanato.prenom as prenom_thanato, ".$this->tableprefix."thanato.id as tid, "
|
||||
.$this->tableprefix."devis.num, ".$this->tableprefix."devis.date, ".$this->tableprefix."devis.version, ".$this->tableprefix."devis.mentions, "
|
||||
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,".$this->tableprefix."devis.id_lieu, "
|
||||
@ -328,14 +329,18 @@ class Bdd {
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
private function getClientsWithClientType(){
|
||||
$sql = "SELECT client.*,'client' as client_type FROM ".$this->tableprefix."client as client;";
|
||||
private function getClientsWithClientType(bool $includeClientInsideGroup = true){
|
||||
$sql = "SELECT client.*,'client' as client_type FROM ".$this->tableprefix."client as client";
|
||||
if($includeClientInsideGroup == false){
|
||||
$sql .= " WHERE client.fk_client_group_facturation_id IS NULL";
|
||||
}
|
||||
$sql .= ";";
|
||||
$clientsWithClientType = $this->execSQLNoJsonReturn($sql,[]);
|
||||
return $clientsWithClientType;
|
||||
}
|
||||
|
||||
public function getClientsAndClientGroupFacturations(){
|
||||
$clients = $this->getClientsWithClientType();
|
||||
public function getClientsAndClientGroupFacturations(bool $includeClientInsideGroup = true){
|
||||
$clients = $this->getClientsWithClientType($includeClientInsideGroup);
|
||||
$clientGroupFacturations = $this->getClientGroupFacturationsWithType();
|
||||
$result = [...$clientGroupFacturations,...$clients];
|
||||
return json_encode($result);
|
||||
|
||||
@ -130,3 +130,14 @@ $('body').on('click', '#cocher', function () {
|
||||
|
||||
$('#cocherparmois').hide();
|
||||
});
|
||||
|
||||
document.onchange = function(event) {
|
||||
if (event.target && event.target.id === 'clientselector') {
|
||||
let selectedOption = event.target.options[event.target.selectedIndex];
|
||||
let filterType = selectedOption.getAttribute('data-type');
|
||||
let filterTypeInput = document.getElementById('filterType');
|
||||
if (filterTypeInput) {
|
||||
filterTypeInput.value = filterType;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -126,7 +126,7 @@ document.body.addEventListener('click', e => {
|
||||
console.log(url);
|
||||
window.location.replace(url);
|
||||
} else if("apercusDevis" === e.target.id) {
|
||||
window.location.replace(generateUrl(`/apps/gestion/devis/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}`));
|
||||
window.location.replace(generateUrl(`/apps/gestion/devis/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}&filterType=group`));
|
||||
} else if("newArticle" === e.target.id) {
|
||||
Article.newArticle(new DataTable('.tabledt'));
|
||||
} else if("newDefunt" == e.target.id) {
|
||||
|
||||
@ -5,7 +5,15 @@
|
||||
<?php
|
||||
foreach ($_['clients'] as $key => $client) {
|
||||
?>
|
||||
<option <?php if(strcmp($_GET['cli'],$client->id)==0) echo 'selected' ?> value='<?php echo $client->id; ?>'><?php echo html_entity_decode($client->prenom).' '.html_entity_decode($client->nom); ?></option>
|
||||
<option
|
||||
<?php
|
||||
if($_GET['cli'] == $client->id && $_GET['filterType'] == $client->client_type){
|
||||
echo 'selected';
|
||||
}
|
||||
?>
|
||||
value='<?php echo $client->id; ?>'>
|
||||
<?php echo strtoupper(html_entity_decode($client->nom)); ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@ -15,9 +23,7 @@
|
||||
<?php
|
||||
$currentYear = date('Y');
|
||||
for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
|
||||
echo '<option value="' . $year . '"';
|
||||
if ((int)$_GET['annee'] == $year) echo ' selected';
|
||||
echo '>' . $year . '</option>';
|
||||
echo '<option value="' . $year . '" ' . ((int)$_GET['annee'] == $year ? 'selected' : '') . '>' . $year . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
@ -36,22 +42,38 @@
|
||||
<option value="11" <?php if((int) $_GET['mois'] == 11) echo 'selected' ?>>Novembre</option>
|
||||
<option value="12" <?php if((int) $_GET['mois'] == 12) echo 'selected' ?>>Decembre</option>
|
||||
</select>
|
||||
<input type="hidden" name="filterType" id="filterType" value="<?php echo ($_GET['filterType'] ?? 'group'); ?>">
|
||||
<input type="submit" value="Filtrer"/>
|
||||
</form>
|
||||
<div class="d-flex flex-row">
|
||||
<?php
|
||||
$clients = $_['clients'];
|
||||
if($_SERVER['REQUEST_METHOD'] == 'GET') {
|
||||
$devis = array_filter($_['devis'], function($d) {
|
||||
if($d->cid){
|
||||
$datesplit = explode("-", $d->date);
|
||||
$devis = array_filter($_['devis'], function($currentDevis) {
|
||||
if($currentDevis->cid){
|
||||
$datesplit = explode("-", $currentDevis->date);
|
||||
$year = (int) $datesplit[0];
|
||||
$month = (int) $datesplit[1];
|
||||
$checkClient = false;
|
||||
if(strcmp($_GET['cli'], '')==0){
|
||||
$checkClient = $_['clients'][0]->id == $d->cid;
|
||||
$filterType = "group";
|
||||
if(array_key_exists('filterType',$_GET) && $_GET['filterType'] == 'client'){
|
||||
$filterType = "client";
|
||||
}
|
||||
$clientIsNotSelected = strcmp($_GET['cli'], '')==0;
|
||||
if($clientIsNotSelected){
|
||||
if($filterType == "group"){
|
||||
$checkClient = $_['clients'][0]->fk_client_group_facturation_id == $currentDevis->cid;
|
||||
}
|
||||
else{
|
||||
$checkClient = $_['clients'][0]->id == $currentDevis->cid;
|
||||
}
|
||||
} else {
|
||||
$checkClient = ((int) $_GET['cli']) == $d->cid;
|
||||
if($filterType == "group"){
|
||||
$checkClient = $currentDevis->fk_client_group_facturation_id == $_GET['cli'];
|
||||
}
|
||||
else{
|
||||
$checkClient = $currentDevis->cid == $_GET['cli'];
|
||||
}
|
||||
}
|
||||
$checkYear = ((int) ($_GET['annee']) == -1)?(true):($year==((int) $_GET['annee']));
|
||||
$checkMounth = (((int) $_GET['mois']) == 0)? (true): ($month==((int) $_GET['mois']));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user