[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/04: Bug #1006 ANCGL : export des pièces d
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/04: Bug #1006 ANCGL : export des pièces dans un grand PDF avec un tampon Task #1006 - ANCGL : export des pièces dans un grand PDF avec un tampon |
Date: |
Fri, 27 Jun 2014 19:24:52 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 7d45e42039ef2b25381d581d6efa6aa658fbb4a0
Author: Dany De Bontridder <address@hidden>
Date: Fri Jun 27 20:58:30 2014 +0200
Bug #1006 ANCGL : export des pièces dans un grand PDF avec un tampon
Task #1006 - ANCGL : export des pièces dans un grand PDF avec un tampon
---
README | 2 +-
html/export.php | 11 ++-
html/js/infobulle.js | 2 +
include/anc_great_ledger.inc.php | 38 ++++++--
include/class_anc_grandlivre.php | 176 ++++++++++++++++++++++---------------
include/class_document_export.php | 160 +++++++++++++++++++++++++++++++++
include/template/template.gif | Bin 0 -> 6626 bytes
release-note | 94 --------------------
sql/upgrade.sql | 48 +---------
9 files changed, 309 insertions(+), 222 deletions(-)
diff --git a/README b/README
index 5547d85..b20ca8f 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
Si vous avez besoin d'aide pour l'installation
utilisez la mailing list
Pour souscrire ou faire des recherches
- aller � http://mail.nongnu.org/mailman/listinfo/phpcompta-support
+ aller � https://lists.nongnu.org/mailman/listinfo/noalyss-generale
diff --git a/html/export.php b/html/export.php
index 8f8bbfb..90b0279 100644
--- a/html/export.php
+++ b/html/export.php
@@ -43,7 +43,14 @@ if ( $action=='X' || ! isset($_GET['act']) ||
$g_user->check_print($_GET['act'])
exit();
}
// get file and execute it
-
- $prfile=$cn->get_value("select me_file from menu_ref where
me_code=$1",array($_GET['act']));
+$action=HtmlInput::default_value_get('act', null);
+if ($action == null )
+{
+ die(_('Appel invalide'));
+}
+ $prfile=$cn->get_value("select me_file from menu_ref where
me_code=$1",array($action));
+ if ( $prfile == "") {
+ die (_('Export impossible'));
+ }
require_once $prfile;
?>
\ No newline at end of file
diff --git a/html/js/infobulle.js b/html/js/infobulle.js
index 36015af..3aa5108 100644
--- a/html/js/infobulle.js
+++ b/html/js/infobulle.js
@@ -64,6 +64,8 @@ content[33]='le type vaut :<ul> <li> ME pour Menu</li>
<li> PR pour les impressi
content[34]='Cliquez sur le code AD pour ouvrir le menu dans un nouvel onglet';
content[35]='Cliquez sur le chemin pour ouvrir le menu';
content[36]='En utilisant les dates d\'échéance ou de paiement, seuls les
journaux de type ACH et VEN seront utilisés ,vous excluez d\'office les autres
journaux';
+content[37]='Les dates sont en format DD.MM.YYYY';
+
function showBulle(p_ctl){
d=document.getElementById('bulle');
d.innerHTML=content[p_ctl];
diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php
index a213355..a304d7e 100644
--- a/include/anc_great_ledger.inc.php
+++ b/include/anc_great_ledger.inc.php
@@ -3,17 +3,37 @@
//see licence.txt
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
-require_once('class_anc_grandlivre.php');
-$gl = new Anc_GrandLivre($cn);
-$gl->get_request();
-echo '<form method="get">';
-echo $gl->display_form();
+
+require_once 'class_anc_grandlivre.php';
+
+$grandLivre=new Anc_Grandlivre($cn);
+
+$grandLivre->get_request();
+
+/*
+ * Form
+ */
+echo '<form method="get" >';
+echo $grandLivre->display_form();
echo '<p>' . HtmlInput::submit('Recherche', _('Recherche')) . '</p>';
+echo HtmlInput::request_to_hidden(array('sa','ac','gDossier'));
echo '</form>';
-if (isset($_GET['result']))
+
+$result=HtmlInput::default_value_request('result',null);
+
+if ($result != null)
{
- echo $gl->show_button();
- echo $gl->display_html();
- echo $gl->show_button();
+ echo '<span style="display:block">';
+ echo _('Tout sélectionner')."
".ICheckBox::toggle_checkbox('export_pdf_bt1','export_anc_receipt_pdf');
+ echo '</span>';
+ echo $grandLivre->show_button();
+ echo '<form method="GET" id="export_anc_receipt_pdf" action="export.php"
style="display:inline">';
+
+ echo $grandLivre->button_export_pdf();
+ echo $grandLivre->display_html();
+ echo $grandLivre->button_export_pdf();
+ echo HtmlInput::get_to_hidden(array('ac','gDossier','sa'));
+ echo '</form>';
+ echo $grandLivre->show_button();
}
?>
diff --git a/include/class_anc_grandlivre.php b/include/class_anc_grandlivre.php
index 28ff9bc..2a3d920 100644
--- a/include/class_anc_grandlivre.php
+++ b/include/class_anc_grandlivre.php
@@ -27,7 +27,8 @@ require_once 'class_impress.php';
class Anc_GrandLivre extends Anc_Print
{
- function set_sql_filter()
+
+ function set_sql_filter()
{
$sql="";
$and=" and ";
@@ -114,7 +115,28 @@ class Anc_GrandLivre extends Anc_Print
return $array;
}
+ /* !
+ * \brief Show the button to export in PDF all the receipt
+ *
+ * \param $p_string extra hidden value
+ * \return string with the button
+ */
+
+ function button_export_pdf($p_string = "")
+ {
+ $r = "";
+ $r.= HtmlInput::hidden("to", $this->to);
+ $r.= HtmlInput::hidden("from", $this->from);
+ $r.= HtmlInput::hidden("pa_id", $this->pa_id);
+ $r.= HtmlInput::hidden("from_poste", $this->from_poste);
+ $r.= HtmlInput::hidden("to_poste", $this->to_poste);
+ $r.= HtmlInput::hidden("act","PDF:AncReceipt");
+ $r.= $p_string;
+ $r.= dossier::hidden();
+ $r.=HtmlInput::submit('bt_receipt_anal_pdf', _("Export des pièces en
PDF"));
+ return $r;
+ }
/*!
* \brief compute the html display
*
@@ -123,79 +145,102 @@ class Anc_GrandLivre extends Anc_Print
*/
function display_html()
- {
- $r="";
+ {
+ $r = "";
//---Html
- $array=$this->load();
- if ( is_array($array) == false )
+ $array = $this->load();
+ if (is_array($array) == false)
{
return $array;
-
}
- if ( empty($array) )
+ if (empty($array))
{
$r.= _("aucune donnée");
return $r;
}
$r.= '<table class="result" style="width=100%">';
- $ix=0;$prev='xx';$idx=0;
- $tot_deb=$tot_cred=0;
-
- foreach ( $array as $row )
+ $ix = 0;
+ $prev = 'xx';
+ $idx = 0;
+ $tot_deb = $tot_cred = 0;
+
+ foreach ($array as $row)
{
- if ($prev != $row['po_name'])
- {
- if ( $ix>0)
- {
- $r.='<tr>';
- $tot_solde=bcsub($tot_cred,$tot_deb);
- $sign=($tot_solde>0)?'C':'D';
- $r.=td('').td('').td('').td('').td('').td(nbm($tot_deb),'
class="num"').td(nbm($tot_cred),' class="num"').td(nbm($tot_solde).$sign,'
class="num"');
- }
- $r.='<tr>'.'<td colspan="7"
style="width:auto">'.'<h2>'.h($row['po_name'].'
'.$row['po_description']).'</td></tr>';
- $r.= '<tr>'.
- '<th>'._('Date').'</th>'.
- '<th>'._('Poste').'</th>'.
- '<th>'._('Quick_code').'</th>'.
- '<th>'._('libelle').'</th>'.
- '<th>'._('Pièce').'</th>'.
- '<th>'._('Num.interne').'</th>'.
- '<th style="text-align:right">'._('Debit').'</th>'.
- '<th style="text-align:right">'._('Credit').'</th>'.
- '</tr>';
+ if ($prev != $row['po_name'])
+ {
+ if ($ix > 0)
+ {
+ $r.='<tr>';
+ $tot_solde = bcsub($tot_cred, $tot_deb);
+ $sign = ($tot_solde > 0) ? 'C' : 'D';
+ $r.=td('') . td('') . td('') . td('') . td('') .
td(nbm($tot_deb), ' class="num"') . td(nbm($tot_cred), ' class="num"') .
td(nbm($tot_solde) . $sign, ' class="num"');
+ }
+ $r.='<tr>' . '<td colspan="7" style="width:auto">' . '<h2>' .
h($row['po_name'] . ' ' . $row['po_description']) . '</td></tr>';
+ $r.= '<tr>' .
+ '<th>' . '</th>' .
+ '<th>' . _('Date') . '</th>' .
+ '<th>' . _('Poste') . '</th>' .
+ '<th>' . _('Quick_code') . '</th>' .
+ '<th>' . _('Libellé') . '</th>' .
+ '<th>' . _('Document') . '</th>' .
+ '<th>' . _('Pièce') . '</th>' .
+ '<th>' . _('Num.interne') . '</th>' .
+ '<th style="text-align:right">' . _('Debit') . '</th>'
.
+ '<th style="text-align:right">' . _('Credit') .
'</th>' .
+ '</tr>';
- $tot_deb=$tot_cred=0;
- $prev=$row['po_name'];
- $ix++;
- }
- $class=($idx%2==0)?'even':'odd'; $idx++;
- $r.='<tr class="'.$class.'">';
- $detail=($row['jr_id'] !=
null)?HtmlInput::detail_op($row['jr_id'],$row['jr_internal']):'';
- $post_detail=($row['j_poste'] !=
null)?HtmlInput::history_account($row['j_poste'],$row['j_poste']):'';
- $card_detail=($row['f_id'] !=
null)?HtmlInput::history_card($row['f_id'],$row['qcode']):'';
- $amount_deb=($row['oa_debit']=='t')?$row['oa_amount']:0;
- $amount_cred=($row['oa_debit']=='f')?$row['oa_amount']:0;
- $tot_deb=bcadd($tot_deb,$amount_deb);
- $tot_cred=bcadd($tot_cred,$amount_cred);
+ $tot_deb = $tot_cred = 0;
+ $prev = $row['po_name'];
+ $ix++;
+ }
+ $class = ($idx % 2 == 0) ? 'even' : 'odd';
+ $idx++;
+ $r.='<tr class="' . $class . '">';
+ $detail = ($row['jr_id'] != null) ?
HtmlInput::detail_op($row['jr_id'], $row['jr_internal']) : '';
+ $post_detail = ($row['j_poste'] != null) ?
HtmlInput::history_account($row['j_poste'], $row['j_poste']) : '';
+ $card_detail = ($row['f_id'] != null) ?
HtmlInput::history_card($row['f_id'], $row['qcode']) : '';
+ $amount_deb = ($row['oa_debit'] == 't') ? $row['oa_amount'] : 0;
+ $amount_cred = ($row['oa_debit'] == 'f') ? $row['oa_amount'] : 0;
+ $tot_deb = bcadd($tot_deb, $amount_deb);
+ $tot_cred = bcadd($tot_cred, $amount_cred);
+
+ /*
+ * Checked button
+ */
+ $str_ck = "";
+ $str_document = "";
+ if ($row['jr_id'] != null)
+ {
+ /*
+ * Get receipt info
+ */
+ $str_document =
HtmlInput::show_receipt_document($row['jr_id']);
+ if ($str_document != "")
+ {
+ $ck = new ICheckBox('ck[]', $row['jr_id']);
+ $str_ck = $ck->input();
+ }
+ }
$r.=
- '<td>'.$row['oa_date'].'</td>'.
- td($post_detail).
- td($card_detail).
- // '<td>'.h($row['oa_description']).'</td>'.
- td($row['jr_comment']).
- td($row['jr_pj_number']).
- '<td>'.$detail.'</td>'.
- '<td class="num">'.nbm($amount_deb).'</td>'.
- '<td class="num">'.nbm($amount_cred)
- .'</td>';
+ '<td>' . $str_ck . '</td>' .
+ '<td>' . $row['oa_date'] . '</td>' .
+ td($post_detail) .
+ td($card_detail) .
+ td($row['jr_comment']) .
+ '<td>' . $str_document . '</td>' .
+ td($row['jr_pj_number']) .
+ '<td>' . $detail . '</td>' .
+ '<td class="num">' . nbm($amount_deb) . '</td>' .
+ '<td class="num">' . nbm($amount_cred)
+ . '</td>';
$r.= '</tr>';
}
- $r.='<tr>';
- $tot_solde=bcsub($tot_cred,$tot_deb);
- $sign=($tot_solde>0)?'C':'D';
- $r.=td('').td('').td('').td('').td('').td(nbm($tot_deb),'
class="num"').td(nbm($tot_cred),' class="num"').td(nbm($tot_solde).$sign,'
class="num"');
+ $r.='<tr>';
+ $tot_solde = bcsub($tot_cred, $tot_deb);
+ $sign = ($tot_solde > 0) ? 'C' : 'D';
+ $r.=td('') . td('') . td('') . td('') . td('') . td(nbm($tot_deb), '
class="num"') . td(nbm($tot_cred), ' class="num"') . td(nbm($tot_solde) .
$sign, ' class="num"');
$r.= '</table>';
return $r;
@@ -212,19 +257,6 @@ class Anc_GrandLivre extends Anc_Print
function show_button($p_string="")
{
$r="";
- /* $r.= '<form method="GET" action="export.php"
style="display:inline">';
- $r.= $p_string;
- $r.= dossier::hidden();
- $r.= HtmlInput::hidden("to",$this->to);
- $r.= HtmlInput::hidden("act","PDF:AncGrandLivre");
-
- $r.= HtmlInput::hidden("from",$this->from);
- $r.= HtmlInput::hidden("pa_id",$this->pa_id);
- $r.= HtmlInput::hidden("from_poste",$this->from_poste);
- $r.= HtmlInput::hidden("to_poste",$this->to_poste);
- $r.=HtmlInput::submit('bt_pdf',"Export en PDF");
- $r.= '</form>';
-*/
$r.= '<form method="GET" action="export.php" style="display:inline">';
$r.= HtmlInput::hidden("act","CSV:AncGrandLivre");
$r.= HtmlInput::hidden("to",$this->to);
diff --git a/include/class_document_export.php
b/include/class_document_export.php
new file mode 100644
index 0000000..b3bc1ee
--- /dev/null
+++ b/include/class_document_export.php
@@ -0,0 +1,160 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of class_export_receipt
+ *
+ * @author dany
+ */
+class Document_Export
+{
+
+ function __construct()
+ {
+ // Create 2 temporary folders 1. convert to PDF + stamp
+ // 2. store result
+ $this->feedback = array();
+ $this->store_convert = tempnam($_ENV['TMP'], 'convert_');
+ $this->store_pdf = tempnam($_ENV['TMP'], 'pdf_');
+ unlink($this->store_convert);
+ unlink($this->store_pdf);
+ umask(0);
+ mkdir($this->store_convert);
+ mkdir($this->store_pdf);
+ }
+
+ function concatenate_pdf()
+ {
+ $stmt = PDFTK . " " . $this->store_pdf . '/stamp_*pdf output ' .
$this->store_pdf . '/result.pdf';
+ $status = 0;
+ echo $stmt;
+ passthru($stmt, $status);
+
+ if ($status <> 0)
+ {
+ $cnt_feedback = count($this->feedback);
+ $this->feedback[$cnt_feedback]['file'] = 'result.pdf';
+ $this->feedback[$cnt_feedback]['message'] = ' cannot concatenate
PDF';
+ $this->feedback[$cnt_feedback]['error'] = $status;
+ }
+ }
+
+ function move_file($p_source, $target)
+ {
+ copy($p_source, $this->store_pdf . '/' . $target);
+ }
+
+ function send_pdf()
+ {
+ header('Content-Type: application/x-download');
+ header('Content-Disposition: attachment; filename="result.pdf"');
+ header('Cache-Control: private, max-age=0, must-revalidate');
+ header('Pragma: public');
+ echo file_get_contents($this->store_pdf . '/result.pdf');
+ }
+
+ function clean_folder()
+ {
+ //unlink($this->store_convert . '/*.pdf');
+ }
+
+ /**
+ * @brief export all the pieces in PDF
+ * @param $p_array contents all the jr_id
+ */
+ function export_all($p_array)
+ {
+ ob_start();
+ var_dump($p_array);
+ global $cn;
+
+ $cn->start();
+ foreach ($p_array as $value)
+ {
+ // For each file save it into the temp folder,
+ $file = $cn->get_array('select
jr_pj,jr_pj_name,jr_pj_number,jr_pj_type from jrn '
+ . ' where jr_id=$1', array($value));
+ if ($file[0]['jr_pj'] == '')
+ continue;
+
+ $cn->lo_export($file[0]['jr_pj'], $this->store_convert . '/' .
$file[0]['jr_pj_name']);
+
+ // Convert this file into PDF
+ if ($file[0]['jr_pj_type'] != 'application/pdf')
+ {
+ $status = 0;
+ passthru(OFFICE . " " . $this->store_convert . '/' .
$file[0]['jr_pj_name'], $status);
+ if ($status <> 0)
+ {
+ $this->feedback[$cnt_feedback]['file'] =
$file[0]['jr_pj_name'];
+ $this->feedback[$cnt_feedback]['message'] = ' cannot
convert to PDF';
+ $this->feedback[$cnt_feedback]['error'] = $status;
+ $cnt_feedback++;
+ continue;
+ }
+ }
+
+ // Create a image with the stamp + formula
+ $img = imagecreatefromgif(__DIR__ . '/template/template.gif');
+ $font = imagecolorallocatealpha($img, 100, 100, 100, 110);
+ imagettftext($img, 40, 25, 500, 1000, $font, __DIR__ .
'/tfpdf/font/unifont/DejaVuSans.ttf', _("Copie certifiée conforme à
l'original"));
+ imagettftext($img, 40, 25, 550, 1100, $font, __DIR__ .
'/tfpdf/font/unifont/DejaVuSans.ttf', $file[0]['jr_pj_number']);
+ imagettftext($img, 40, 25, 600, 1200, $font, __DIR__ .
'/tfpdf/font/unifont/DejaVuSans.ttf', $file[0]['jr_pj_name']);
+ imagegif($img, $this->store_convert . '/' . 'stamp.gif');
+
+ // transform gif file to pdf with convert tool
+ $stmt = CONVERT_GIF_PDF . " " .
escapeshellarg($this->store_convert . '/' . 'stamp.gif') . " " .
escapeshellarg($this->store_convert . '/stamp.pdf');
+ passthru($stmt, $status);
+
+ if ($status <> 0)
+ {
+ $this->feedback[$cnt_feedback]['file'] = 'stamp.pdf';
+ $this->feedback[$cnt_feedback]['message'] = ' cannot convert
to PDF';
+ $this->feedback[$cnt_feedback]['error'] = $status;
+ $cnt_feedback++;
+ continue;
+ }
+
+ //
+ // remove extension
+ $ext = strrpos($file[0]['jr_pj_name'], ".");
+ $file_pdf = substr($file[0]['jr_pj_name'], 0, $ext);
+ $file_pdf .=".pdf";
+
+ // output
+ $output = $this->store_convert . '/stamp_' . $file_pdf;
+
+ // Concatenate stamp + file
+ $stmt = PDFTK . " " . escapeshellarg($this->store_convert . '/' .
$file_pdf) . ' stamp ' . $this->store_convert .
+ '/stamp.pdf output ' . $output;
+
+ passthru($stmt, $status);
+ echo $stmt;
+ if ($status <> 0)
+ {
+
+ $this->feedback[$cnt_feedback]['file'] = $file_pdf;
+ $this->feedback[$cnt_feedback]['message'] = ' cannot convert
to stamped PDF';
+ $this->feedback[$cnt_feedback]['error'] = $status;
+ $cnt_feedback++;
+ continue;
+ }
+ // Move the PDF into another temp directory
+ $this->move_file($output, 'stamp_' . $file_pdf);
+ }
+ $this->concatenate_pdf();
+ ob_clean();
+ $this->send_pdf();
+
+ // remove files from "conversion folder"
+ $this->clean_folder();
+ var_dump($this->feedback);
+ // concatenate all pdf into one
+ }
+
+}
diff --git a/include/template/template.gif b/include/template/template.gif
new file mode 100644
index 0000000..ab44205
Binary files /dev/null and b/include/template/template.gif differ
diff --git a/release-note b/release-note
deleted file mode 100644
index 27a2134..0000000
--- a/release-note
+++ /dev/null
@@ -1,94 +0,0 @@
-===================================================================
-|| Done
-===================================================================
-
-Favori
-======
-Permet d'avoir une liste qui apparaît dans une fenêtre interne avec
-les menus que vous utilisez le plus
-
-Navigateur
-==========
-Permet d'accèder rapidement au menu nécessaire, il y a plus
-d'explication sur les menu
-
-Impression journaux
-===================
-Anciennement appelé impression - historique -> changer dans menu_ref
-Permet impression des journaux vente et achat avec détail pour la TVA, la
partie
-non déductible et la partie privée
-
-Modéle d'opération
-==================
-Amélioration : Fenêtre interne avec filtrage et une description des
-modèles, la limite est plus élevée aussi
-
-Impression journaux
-===================
-Anciennement appelé impression - historique -> changer dans menu_ref
-Permet impression des journaux vente et achat avec détail pour la TVA, la
partie
-non déductible et la partie privée
-
-
-Protection fichier include
-==========================
-Ajout d'une sécurité supplémentaire
-
-Préférence
-==========
-Dans fenêtre interne
-
-Action - Suivi
-===============
-1. Ajout de tags (table tag et action_tag) (v)
-2. changement présentation liste (x)
-3. Ajout menu : CFGTAG pour gèrer les tags : description, nom ...
-4. Ajout d'un ou plusieurs tags par action, un tag n'est pas un type de
document
- Sécurité : vérifier que l'utilisateur peut ajouter ou enlever des tags à une
action
-Changement présentation Détail action : les détails (qui/quand) sont à mettre
dans la colonne de gauche
-
-Journaux
-========
-Suivi type de journal montrer ou cacher les bons détails
-Pour ACH indiquer Fournisseur (D) et Services ou Marchandises achetés
-Pour VEN indiquer Client (C) et Services ou Marchandises vendus
-Pour FIN indiquer Compte tiers (D/C) et surtout permettre de créer un fiche de
type trésorerie (frd_id=4)
-
-Fiche
-=====
-Si aucun quickcode n'est donné, il en sera calculé un en se basant sur le nom
de la fiche (5ière lettre) + n° si duplicate
-code php
-fiche_def.inc.php
-
-Action - Suivi
-===============
-Recherche par tag
-L'avoir dans les changements de page
-Tag repris dans le bouton retour
-Visible dans la recherche après une recherche
-Possibilité d'ajouter / enlever des tags à plusieurs documents
-Possibilité d'avoir une impression web de plusieurs documents
-Possibilité de changer l'état de plusieurs documents
-
-Date de paiement
-================
-Lors de rapprochement
-Dans le détail journaux ACH et VEN
-Dans l'impression PRINTJRN + export CSV
-Dans l'historique
-
-===================================================================
-|| A faire
-===================================================================
-
-
-Document à générer
-=================
-Par journal
-ou par profil
-
-
-
-
-
-
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 27bd799..26c24e0 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -1,48 +1,8 @@
insert into fiche_def_ref(frd_id,frd_text) values (26,'Projet');
insert into attr_min (frd_id,ad_id) values (26,1),(26,9);
-DROP VIEW v_detail_purchase;
+INSERT INTO menu_ref(
+ me_code, me_menu, me_file, me_type)
+ VALUES ('PDF:AncReceipt', 'Export pièce PDF',
'export_anc_receipt_pdf.php','PR');
-CREATE OR REPLACE VIEW v_detail_purchase AS
- WITH m AS (
- SELECT sum(quant_purchase.qp_price) AS htva,
sum(quant_purchase.qp_vat) AS tot_vat, jrn.jr_id
- FROM quant_purchase
- JOIN jrnx USING (j_id)
- JOIN jrn ON jrnx.j_grpt = jrn.jr_grpt_id
- GROUP BY jrn.jr_id
- )
- SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid,jr_ech,
- jrn.jr_tech_per, jrn.jr_comment,
- jrn.jr_pj_number, jrn.jr_internal,
- jrn.jr_def_id, jrnx.j_poste,
- jrnx.j_text, jrnx.j_qcode,
- quant_purchase.qp_fiche AS item_card, a.name AS item_name,
- quant_purchase.qp_supplier, b.vw_name AS tiers_name,
- b.quick_code, tva_rate.tva_label,
- tva_rate.tva_comment, tva_rate.tva_both_side, quant_purchase.qp_vat_sided AS
vat_sided, quant_purchase.qp_vat_code AS vat_code, quant_purchase.qp_vat AS
vat, quant_purchase.qp_price AS price, quant_purchase.qp_quantite AS quantity,
quant_purchase.qp_price / quant_purchase.qp_quantite AS price_per_unit,
quant_purchase.qp_nd_amount AS non_ded_amount, quant_purchase.qp_nd_tva AS
non_ded_tva, quant_purchase.qp_nd_tva_recup AS non_ded_tva_recup, m.htva,
m.tot_vat
- FROM jrn
- JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
- JOIN quant_purchase USING (j_id)
- JOIN vw_fiche_name a ON quant_purchase.qp_fiche = a.f_id
- JOIN vw_fiche_attr b ON quant_purchase.qp_supplier = b.f_id
- JOIN tva_rate ON quant_purchase.qp_vat_code = tva_rate.tva_id
- JOIN m ON m.jr_id = jrn.jr_id;
-
-DROP VIEW v_detail_sale;
-
-CREATE OR REPLACE VIEW v_detail_sale AS
- WITH m AS (
- SELECT sum(quant_sold.qs_price) AS htva, sum(quant_sold.qs_vat) AS
tot_vat, jrn.jr_id
- FROM quant_sold
- JOIN jrnx USING (j_id)
- JOIN jrn ON jrnx.j_grpt = jrn.jr_grpt_id
- GROUP BY jrn.jr_id
- )
- SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid,jr_ech,jrn.jr_tech_per,
jrn.jr_comment, jrn.jr_pj_number, jrn.jr_internal, jrn.jr_def_id, jrnx.j_poste,
jrnx.j_text, jrnx.j_qcode, quant_sold.qs_fiche AS item_card, a.name AS
item_name, quant_sold.qs_client, b.vw_name AS tiers_name, b.quick_code,
tva_rate.tva_label, tva_rate.tva_comment, tva_rate.tva_both_side,
quant_sold.qs_vat_sided AS vat_sided, quant_sold.qs_vat_code AS vat_code,
quant_sold.qs_vat AS vat, quant_sold.qs_price AS price, [...]
- FROM jrn
- JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
- JOIN quant_sold USING (j_id)
- JOIN vw_fiche_name a ON quant_sold.qs_fiche = a.f_id
- JOIN vw_fiche_attr b ON quant_sold.qs_client = b.f_id
- JOIN tva_rate ON quant_sold.qs_vat_code = tva_rate.tva_id
- join m on m.jr_id=jrn.jr_id;
\ No newline at end of file
+insert into profile_menu(me_code,p_id,p_type_display,pm_default) values
('PDF:AncReceipt',1,'P',0);
\ No newline at end of file