Exemplo n.º 1
0
 function build_tmp_table($p_array)
 {
     global $cn, $g_user;
     // exercice
     if (isset($p_array['state_exercice'])) {
         $periode = new Periode($cn);
         $date = format_date($p_array['state_exercice'], 'YYYY-MM-DD');
         $periode->find_periode($date);
     } else {
         $periode_id = $g_user->get_periode();
         $periode = new Periode($cn, $periode_id);
     }
     $periode->load();
     $tmp_id = $cn->get_next_seq("public.tmp_stockgood_s_id_seq");
     $cn->exec_sql("delete from tmp_stockgood where s_date < now() - interval '2 days' ");
     $cn->exec_sql("insert into tmp_stockgood(s_id) values (\$1)", array($tmp_id));
     // get all readable repository
     $a_repository = $g_user->get_available_repository('R');
     // From ACH : IN
     $sql_repo_detail = "\n\t\t\tinsert into tmp_stockgood_detail(s_id,sg_code,s_qin,r_id,f_id)\n\t\t\t\tselect {$tmp_id},trim(sg_code), coalesce(sum(sg_quantity),0) as qin,r_id,f_id\n\t\t\t\tfrom stock_goods\n\t\t\t\twhere\n\t\t\t\t\tsg_type='d'\n\t\t\t\t\tand j_id is not null\n\t\t\t\t\tand j_id in (select j_id from jrnx where  j_tech_per in (select p_id from parm_periode where p_exercice=\$2))\n\t\t\t\t\tand r_id  in (select r_id from profile_sec_repository where p_id=\$1)\n\t\t\t\t\tgroup by r_id,trim(sg_code),f_id\n\t\t\t";
     // From VEN : out
     $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
     $sql_repo_detail = "\n\t\t\t\tinsert into tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)\n\t\t\t\tselect {$tmp_id},trim(sg_code) , coalesce(sum(sg_quantity),0) as qout,r_id,f_id\n\t\t\t\tfrom stock_goods as sg\n\t\t\t\twhere\n\t\t\t\t\tsg_type='c'\n\t\t\t\t\tand sg.j_id is not null\n\t\t\t\t\tand sg.j_id in (select j_id from jrnx where  j_tech_per in (select p_id from parm_periode where p_exercice=\$2))\n\t\t\t\t\tand sg.r_id  in (select r_id from profile_sec_repository where p_id=\$1)\n\t\t\t\t\tgroup by r_id,trim(sg_code),f_id\n\t\t\t";
     $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
     // From INV  IN
     $sql_repo_detail = "\n\t\t\tinsert into tmp_stockgood_detail(s_id,sg_code,s_qin,r_id,f_id)\n\t\t\t\tselect {$tmp_id},trim(sg_code) , coalesce(sum(sg_quantity),0) as qin,r_id,f_id\n\t\t\t\tfrom stock_goods as sg\n\t\t\t\twhere\n\t\t\t\t\tsg_type='d'\n\t\t\t\t\tand j_id is null\n\t\t\t\t\tand sg_date >= ( select min(p_start) from parm_periode where p_exercice=\$2)\n\t\t\t\t\tand sg_date <= ( select max(p_end) from parm_periode where p_exercice=\$2)\n\t\t\t\t\t and sg.r_id  in (select r_id from profile_sec_repository where p_id=\$1)\n\t\t\t\t\tgroup by r_id,trim(sg_code),f_id\n\t\t\t";
     // From INV: OUT
     $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
     $sql_repo_detail = "\n\t\t\t\tinsert into tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)\n\t\t\t\tselect {$tmp_id},trim(sg_code), coalesce(sum(sg_quantity),0) as qout,r_id,f_id\n\t\t\t\tfrom stock_goods\n\t\t\t\twhere\n\t\t\t\t\tsg_type='c'\n\t\t\t\t\tand j_id is null\n\t\t\t\t\t and r_id  in (select r_id from profile_sec_repository where p_id=\$1)\n                                        and sg_date >= ( select min(p_start) from parm_periode where p_exercice=\$2)\n\t\t\t\t\tand sg_date <= ( select max(p_end) from parm_periode where p_exercice=\$2)\t\t\t\t\t\n                                        group by r_id,trim(sg_code),f_id\n\t\t\t";
     $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), $periode->p_exercice));
     return $tmp_id;
 }
Exemplo n.º 2
0
 function get_limit($p_exercice)
 {
     $max = $this->cn->get_value("select p_id from parm_periode where p_exercice=\$1 order by p_start asc limit 1", array($p_exercice));
     $min = $this->cn->get_value("select p_id from parm_periode where p_exercice=\$1 order by p_start desc limit 1", array($p_exercice));
     $rMax = new Periode($this->cn);
     $rMax->p_id = $max;
     if ($rMax->load()) {
         throw new Exception('Periode n\'existe pas');
     }
     $rMin = new Periode($this->cn);
     $rMin->p_id = $min;
     if ($rMin->load()) {
         throw new Exception('Periode n\'existe pas');
     }
     return array($rMax, $rMin);
 }
Exemplo n.º 3
0
 *   along with NOALYSS; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**
 * @file
 * @brief show the state of the repository
 *
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
global $cn, $g_parameter, $g_user;
require_once NOALYSS_INCLUDE . '/class_stock.php';
// Show the form
// Get by exercice
// Get type = table or list
$iexercice = new ISelect('state_exercice');
$iexercice->value = $cn->make_array("select  max(p_end) as date_end, p_exercice from parm_periode  group by p_exercice order by 2 desc");
$per = new Periode($cn, $g_user->get_periode());
$per->load();
$date_limit = $per->limit_year($per->p_exercice);
$last_day = $per->last_day($date_limit['end']);
$last_day = format_date($last_day, 'DD.MM.YYYY', 'YYYY-MM-DD');
$iexercice->selected = isset($_GET['state_exercice']) ? $_GET['state_exercice'] : $last_day;
$presentation = new ISelect("present");
$presentation->value = array(array("value" => "T", "label" => "Tableau récapitulatif"), array("value" => "L", "label" => "Liste"));
$presentation->selected = isset($_GET['present']) ? $_GET['present'] : "T";
require_once NOALYSS_INCLUDE . '/template/stock_state_search.php';
$stock = new Stock($cn);
$stock->summary($_GET);
Exemplo n.º 4
0
if (DBVERSION > dossier::get_version($cn)) {
    echo '<h2 class="error" style="font-size:12px">' . _("Votre base de données n'est pas à jour") . '   ';
    $a = _("cliquez ici pour appliquer le patch");
    $base = dirname($_SERVER['REQUEST_URI']);
    if ($base == '/') {
        $base = '';
    }
    $base .= '/admin/setup.php';
    echo '<a hreF="' . $base . '">' . $a . '</a></h2>';
}
/*
 * Set a correct periode for the user
 */
$periode = $g_user->get_periode();
$oPeriode = new Periode($cn, $periode);
if ($oPeriode->load() == -1) {
    $periode = $cn->get_value('select p_id from parm_periode order by p_start asc limit 1');
    $g_user->set_periode($periode);
}
$module_selected = -1;
/*
 * Set the user preference
 */
if (isset($_POST['set_preference'])) {
    //// Save value
    extract($_POST);
    if (strlen(trim($pass_1)) != 0 && strlen(trim($pass_2)) != 0) {
        $g_user->save_password($pass_1, $pass_2);
    }
    $g_user->set_periode($period);
    $g_user->save_global_preference('THEME', $style_user);