';
echo '
';
-$str="if (g('histo').value==3) {
+$str = "if (g('histo').value==3 || g('histo').value== -1 ) {
g('trstart').style.display='none';g('trend').style.display='none';g('allcard').style.display='none';}
- else {g('trstart').style.display='';g('trend').style.display='';g('allcard').style.display='';}";
+ else {g('trstart').style.display='';g('trend').style.display='';g('allcard').style.display='';}
+ if ( g('histo').value== -1 ) { g('allcard').style.display='';}
+
+ ";
echo create_script($str);
echo '
';
//-----------------------------------------------------
-if ( ! isset($_GET['cat_display']))
- exit();
+if (!isset($_GET['cat_display']))
+ exit();
-$array=Fiche::get_fiche_def($cn,$_GET['cat'],'name_asc');
+$fd_id = $_GET['cat'];
+$array = Fiche::get_fiche_def($cn, $_GET['cat'], 'name_asc');
+
+$h_add_card_b = new IButton('add_card');
+$h_add_card_b->label = _('Créer une nouvelle fiche');
+$h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id})";
+$str_add_card = ($g_user->check_action(FICADD) == 1) ? $h_add_card_b->input() : "";
/*
* You show now the result
*/
-if ($array == null )
+if ($array == null)
{
- echo '
Aucune fiche trouvée
';
- exit();
+ echo '
Aucune fiche trouvée
';
+ echo $str_add_card;
+ exit();
}
-$allcard=(isset($_GET['allcard']))?1:0;
-// summary
-if ( $_GET['histo'] == 3 )
+$allcard = (isset($_GET['allcard'])) ? 1 : 0;
+/* * *********************************************************************************************************************************
+ * Liste
+ *
+ * ******************************************************************************************************************************** */
+if ($_GET['histo'] == -1)
{
- $cat_card=new Fiche_Def($cn);
- $cat_card->id=$_GET['cat'];
- $aHeading=$cat_card->getAttribut();
- require_once('template/result_cat_card_summary.php');
-
- $hid=new IHidden();
- echo '
";
-
- exit();
-}
-$export_pdf='
';
-
-$export_print=HtmlInput::print_window();
-
-$export_csv='
';
-
-// Balance
-if ( $_GET['histo'] == 4 || $_GET['histo']==5 )
-{
- if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null )
- {
- echo h2('Date invalide !','class="error"');
- alert('Date invalide !');
- exit;
- }
- echo $export_pdf;
- echo $export_csv;
- echo $export_print;
-
- $fd=new Fiche_Def($cn,$_REQUEST['cat']);
- if ( $allcard==0 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
- {
- echo alert("Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
- exit;
- }
- // all card
- if ($allcard==1)
+ $write = $g_user->check_action(FICADD);
+ /**
+ * If ask for move or delete
+ */
+ if (isset($_POST['action']))
{
- $afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
+ if ($write == 1)
+ {
+ $ack = $_POST['f_id'];
+ /**
+ * Move
+ */
+ if (isset($_POST['move']))
+ {
+ for ($i = 0; $i < count($ack); $i++)
+ {
+ $fiche = new Fiche($cn, $ack[$i]);
+ $fiche->move_to($_POST['move_to']);
+ }
+ }
+ /**
+ * Delete
+ */
+ if (isset($_POST['delete']))
+ {
+ $msg="";
+ for ($i = 0; $i < count($ack); $i++)
+ {
+ $fiche = new Fiche($cn, $ack[$i]);
+ if ( $fiche->remove(true) == 1 )
+ {
+ $msg.="\n ".$fiche->strAttribut(ATTR_DEF_QUICKCODE);
+ }
+ }
+ if ($msg != "")
+ {
+ echo h2("Fiche non effacées", ' class="error" ');
+ echo '
'." Ces fiches n'ont pas été effacées ".$msg;
+ }
+ }
+ }
+ else
+ {
+ echo NoAccess();
+ }
+ }
+ $sql = "select f_id from fiche ";
+ if ($allcard == 1)
+ {
+ $cond = "";
}
else
{
- $afiche[0]=array('fd_id'=>$_REQUEST['cat']);
+ $cond = " where fd_id = " . sql_string($_GET['cat']);
+ }
+ // Create nav bar
+ $max = $cn->get_value("select count(*) from fiche " . $cond);
+
+ $step = $_SESSION['g_pagesize'];
+ $page = (isset($_GET['offset'])) ? $_GET['page'] : 1;
+ $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
+ $bar = navigation_bar($offset, $max, $step, $page);
+ $limit = ($step == -1 ) ? "" : " limit " . $step;
+ $res = $cn->exec_sql("
+ select f_id,
+ (select ad_value from fiche_detail as fd1 where ad_id=1 and fd1.f_id=f.f_id) as name,
+ (select ad_value from fiche_detail as fd1 where ad_id=23 and fd1.f_id=f.f_id) as qcode
+ from fiche as f
+ $cond order by 1 offset $offset $limit
+ ");
+ $nb_line = Database::num_row($res);
+ require_once 'template/fiche_list.php';
+ if ($write == 1 ) echo $str_add_card;
+ exit();
+}
+/* * *********************************************************************************************************************************
+ * Summary
+ *
+ * ******************************************************************************************************************************** */
+if ($_GET['histo'] == 3)
+{
+ $cat_card = new Fiche_Def($cn);
+ $cat_card->id = $_GET['cat'];
+ $aHeading = $cat_card->getAttribut();
+ echo $str_add_card;
+ require_once('template/result_cat_card_summary.php');
+
+ $hid = new IHidden();
+ echo '
";
+
+ exit();
+}
+$export_pdf = '
';
+
+$export_print = HtmlInput::print_window();
+
+$export_csv = '
';
+
+/********************************************************************************************************************************
+ * Balance
+ *
+ **********************************************************************************************************************************/
+if ($_GET['histo'] == 4 || $_GET['histo'] == 5)
+{
+ if (isDate($_REQUEST['start']) == null || isDate($_REQUEST['end']) == null)
+ {
+ echo h2('Date invalide !', 'class="error"');
+ alert('Date invalide !');
+ exit;
+ }
+ echo $str_add_card;
+ echo $export_pdf;
+ echo $export_csv;
+ echo $export_print;
+
+ $fd = new Fiche_Def($cn, $_REQUEST['cat']);
+ if ($allcard == 0 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false)
+ {
+ echo alert("Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
+ exit;
+ }
+ // all card
+ if ($allcard == 1)
+ {
+ $afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
+ }
+ else
+ {
+ $afiche[0] = array('fd_id' => $_REQUEST['cat']);
}
- for ($e=0;$e
exec_sql("select f_id,ad_value from fiche join fiche_detail using(f_id) where fd_id=$1 and ad_id=1 order by 2 ",array($afiche[$e]['fd_id']));
- if ( $cn->count()==0 )
+ $ret = $cn->exec_sql("select f_id,ad_value from fiche join fiche_detail using(f_id) where fd_id=$1 and ad_id=1 order by 2 ", array($afiche[$e]['fd_id']));
+ if ($cn->count() == 0)
{
- if ( $allcard==0) {
+ if ($allcard == 0)
+ {
echo "Aucune fiche trouvée";
exit;
} else
continue;
}
- echo ''.$cn->get_value("select fd_label from fiche_def where fd_id=$1",array($afiche[$e]['fd_id'])).'
';
+ echo '' . $cn->get_value("select fd_label from fiche_def where fd_id=$1", array($afiche[$e]['fd_id'])) . '
';
echo '';
echo tr(
- th('Quick Code').
- th('Libellé').
- th('Débit','style="text-align:right"').
- th('Crédit','style="text-align:right"').
- th('Solde','style="text-align:right"').
- th('D/C','style="text-align:right"')
+ th('Quick Code') .
+ th('Libellé') .
+ th('Débit', 'style="text-align:right"') .
+ th('Crédit', 'style="text-align:right"') .
+ th('Solde', 'style="text-align:right"') .
+ th('D/C', 'style="text-align:right"')
);
- $idx=0;
- for ($i=0;$i < Database::num_row($ret);$i++)
+ $idx = 0;
+ for ($i = 0; $i < Database::num_row($ret); $i++)
{
- $filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ".
- " and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) ";
- $aCard=Database::fetch_array($ret,$i);
- $oCard=new Fiche($cn,$aCard['f_id']);
- $solde=$oCard->get_solde_detail($filter);
- if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
- /* only not purged card */
- if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) continue;
- $class='';
- if ( $idx%2 == 0) $class='class="odd"';
+ $filter = " (j_date >= to_date('" . $_REQUEST['start'] . "','DD.MM.YYYY') " .
+ " and j_date <= to_date('" . $_REQUEST['end'] . "','DD.MM.YYYY')) ";
+ $aCard = Database::fetch_array($ret, $i);
+ $oCard = new Fiche($cn, $aCard['f_id']);
+ $solde = $oCard->get_solde_detail($filter);
+ if ($solde['debit'] == 0 && $solde['credit'] == 0)
+ continue;
+ /* only not purged card */
+ if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit'])
+ continue;
+ $class = '';
+ if ($idx % 2 == 0)
+ $class = 'class="odd"';
$idx++;
echo tr(
- td(HtmlInput::history_card($oCard->id,$oCard->strAttribut(ATTR_DEF_QUICKCODE))).
- td($oCard->strAttribut(ATTR_DEF_NAME)).
- td(nbm($solde['debit']),'style="text-align:right"').
- td(nbm($solde['credit']),'style="text-align:right"').
- td(nbm(abs($solde['solde'])),'style="text-align:right"').
- td((($solde['debit']<$solde['credit'])?'CRED':'DEB'),'style="text-align:right"'),
- $class
+ td(HtmlInput::history_card($oCard->id, $oCard->strAttribut(ATTR_DEF_QUICKCODE))) .
+ td($oCard->strAttribut(ATTR_DEF_NAME)) .
+ td(nbm($solde['debit']), 'style="text-align:right"') .
+ td(nbm($solde['credit']), 'style="text-align:right"') .
+ td(nbm(abs($solde['solde'])), 'style="text-align:right"') .
+ td((($solde['debit'] < $solde['credit']) ? 'CRED' : 'DEB'), 'style="text-align:right"'), $class
);
-
}
echo '
';
}
- echo $export_pdf;
- echo $export_csv;
- echo $export_print;
+ echo $str_add_card;
+ echo $export_pdf;
+ echo $export_csv;
+ echo $export_print;
- exit();
+ exit();
}
-if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null )
+if (isDate($_REQUEST['start']) == null || isDate($_REQUEST['end']) == null)
{
- echo h2('Date invalide !','class="error"');
- alert('Date invalide !');
- exit;
+ echo h2('Date invalide !', 'class="error"');
+ alert('Date invalide !');
+ exit;
}
-//----------------------------------------------------------------------------
-// for the lettering / history
-//----------------------------------------------------------------------------
-
+/***********************************************************************************************************************************
+ * Lettering
+ *
+ **********************************************************************************************************************************/
// all card
-if ($allcard==1)
+if ($allcard == 1)
{
- $afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
+ $afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
}
else
{
- $afiche[0]=array('fd_id'=>$_REQUEST['cat']);
+ $afiche[0] = array('fd_id' => $_REQUEST['cat']);
}
+echo $str_add_card;
echo $export_csv;
echo $export_pdf;
echo $export_print;
-$fiche=new Fiche($cn);
+$fiche = new Fiche($cn);
for ($e = 0; $e < count($afiche); $e++)
{
$array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
@@ -276,7 +382,7 @@ for ($e = 0; $e < count($afiche); $e++)
{
$letter->get_unletter();
}
- if ( $_GET['histo'] == 6 )
+ if ($_GET['histo'] == 6)
{
$letter->get_letter_diff();
}
@@ -285,7 +391,7 @@ for ($e = 0; $e < count($afiche); $e++)
continue;
$detail_card = HtmlInput::card_detail($row->strAttribut(ATTR_DEF_QUICKCODE), $row->strAttribut(ATTR_DEF_NAME));
- echo '' . $detail_card . '
';
+ echo '' . $detail_card . '
';
echo '';
echo '';
@@ -326,14 +432,15 @@ for ($e = 0; $e < count($afiche); $e++)
$amount_cred+=$row['j_montant'];
$prog = bcsub($prog, $row['j_montant']);
}
- $side=" ".$fiche->get_amount_side($prog);
- echo td(nbm($prog).$side, 'style="text-align:right"');
+ $side = " " . $fiche->get_amount_side($prog);
+ echo td(nbm($prog) . $side, 'style="text-align:right"');
if ($row['letter'] != -1)
- {
- $span_error="";
- if ( $row['letter_diff'] != 0 ) $span_error=$g_failed;
- echo td($row['letter'].$span_error);
- }
+ {
+ $span_error = "";
+ if ($row['letter_diff'] != 0)
+ $span_error = $g_failed;
+ echo td($row['letter'] . $span_error);
+ }
else
echo td('');
echo '
';
@@ -359,10 +466,9 @@ for ($e = 0; $e < count($afiche); $e++)
echo '
';
}
}
+echo $str_add_card;
echo $export_csv;
echo $export_pdf;
echo $export_print;
-
-
?>
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index d8d8c42be..1bf2e2186 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -472,5 +472,8 @@ CREATE INDEX quant_sold_jrn_fki
create sequence uos_pk_seq;
create table tool_uos ( uos_value bigint default nextval ('uos_pk_seq') primary key );
-update menu_ref set me_code='CFGCARD',me_file='cfgfiche.inc.php' where me_code='CARD';
-update menu_ref set me_code='CARD',me_file='fiche.inc.php' where me_code='PRINTCARD';
+-- update menu_ref set me_code='CFGCARD',me_file='cfgfiche.inc.php' where me_code='CARD';
+-- update menu_ref set me_code='CARD',me_file='fiche.inc.php' where me_code='PRINTCARD';
+-- update profile_menu set me_code='CARD' where me_code='CFGCARD';
+-- update profile_menu set me_code='CFGCARD' , me_code_dep='PARAM' where me_code='CARD' and me_code_dep='PRINT';
+-- update menu_ref set me_menu='Fiche',me_description='Liste,Balance,Historique par fiche' where me_code='CARD'