Example #1
0
    function getKind()
    {
        $sql = 'SELECT org.id, org.navn, org.kortnavn, org.orgnr
		    FROM org
		    WHERE org.id IN (
		        SELECT org_id
		            FROM tjenesteabonnement
		                JOIN status_codes_tjenesteabonnement ON tjenesteabonnement.status = status_codes_tjenesteabonnement.id
		                JOIN tjeneste ON tjenesteabonnement.tjeneste_id = tjeneste.id
		            WHERE status_codes_tjenesteabonnement.status=\'Installert\'
		                AND tjeneste.navn = \'urn:mace:feide.no:services:no.uninett.feidekundeportal\'
        )';
        $res = pg_query($this->db, $sql);
        $data = array();
        while ($row = pg_fetch_row($res)) {
            $newEntry = array('orgnr' => FeedBuilder::slim($row[3]), 'kind.kortnavn' => $row[2], 'kind.title' => $row[1], 'kind.id' => $row[0]);
            // $this->add(array('id' => $row[0]), $newEntry);
            // $this->addEntry($newEntry);
            // print_r($newEntry);
            $data[] = $newEntry;
            if (preg_match('/ kommune/', $row[0])) {
            }
        }
        return $data;
    }
Example #2
0
 public function version()
 {
     if ($this->vval === NULL) {
         $this->vval = pg_fetch_row(pg_query($this->res, 'SELECT version()'), 0);
     }
     return $this->vval;
 }
Example #3
0
function getStartEndDate($cons_id)
{
    $query = "select subscriptioneffectivedate,subscriptionenddate from techmatcher.currentsubscribers_vw where itconsumer_id = \$1;";
    $result = pg_query_params($query, array($cons_id));
    $row = pg_fetch_row($result);
    return $row;
}
Example #4
0
 /**
  *
  * @param type $query
  * @param type $type
  * @return type
  */
 public function execute($query, $type = null)
 {
     $result = array();
     switch ($this->db_engine) {
         case "pgsql":
             $resultado = pg_query($this->conn, $query);
             while ($row = pg_fetch_row($resultado)) {
                 $result[] = $row;
             }
             pg_close($this->conn);
             break;
         case "mssql":
             $resultado = odbc_exec($this->conn, $query);
             while ($row = odbc_fetch_array($resultado)) {
                 $result[] = $row;
             }
             break;
         case "mysql":
             $result = array();
             $resultado = mysql_query($query);
             if (gettype($resultado) == "boolean") {
                 $result = $resultado;
             } else {
                 while ($row = mysql_fetch_row($resultado)) {
                     $result[] = $row;
                 }
             }
             mysql_close($this->conn);
             break;
     }
     return $result;
 }
 public function Afficher()
 {
     // - On se connecte à la base de données
     parent::ConnecterBD();
     // - on récupère des infos de la session
     $account_id = $_SESSION['account_id'];
     // - on récupère les paramètres
     $message_id = $_GET['no_message'];
     // - On récupère les données
     $sql = "SELECT is_read, object, message, date_envoi FROM \"libertribes\".\"MESSAGE\" WHERE account_id = {$account_id} AND message_id = {$message_id} AND type = 1 AND is_delete = 0";
     $result = parent::Requete($sql);
     if ($result) {
         $row = pg_fetch_row($result);
         if ($row) {
             // - on stocke le message
             $_SESSION['messagerie_lire_id'] = $message_id;
             $_SESSION['messagerie_lire_is_read'] = $row[0];
             $_SESSION['messagerie_lire_object'] = $row[1];
             $_SESSION['messagerie_lire_message'] = $row[2];
             $_SESSION['messagerie_lire_date_envoi'] = $row[3];
             $_SESSION['messagerie_lire_heure_envoi'] = "XXhXX";
         }
     }
     parent::Afficher();
     // - gestion spécifique de la page
 }
Example #6
0
 function fetch_referendums($status, $start, $pagelen, $search, $order)
 {
     global $dbconn, $expanded_referendums;
     global $sql_names;
     global $sql_select, $sql_from, $sql_where;
     global $sql_fud_names, $sql_fud_select, $sql_fud_from, $sql_fud_where;
     global $sql_type_select, $sql_type_from, $sql_type_where;
     $sql_fetch = " from" . "  (select " . $sql_select . $sql_fud_select . $sql_type_select . "    from " . $sql_from . $sql_fud_from . $sql_type_from . "    where " . $sql_where . $sql_fud_where . $sql_type_where . "    order by i.referendum) as v" . " where " . $search;
     $sql = "select count(*) from (select distinct on (referendum) referendum " . $sql_fetch . " group by referendum) as r";
     $row = pg_fetch_row(pg_query($dbconn, $sql)) or die('Could query: ' . pg_last_error());
     $len = (int) $row[0];
     $sql = "select * " . $sql_fetch . " order by " . $order;
     " limit " . ($start + $pagelen);
     $rows = pg_query($dbconn, $sql) or die('Could query: ' . pg_last_error());
     pg_result_seek($rows, $start);
     $v = array();
     while ($row = pg_fetch_row($rows)) {
         $row = array_combine($sql_names, $row);
         $row['expanded'] = in_array($row['referendum'], $expanded_referendums);
         if (!isset($v[count($v) - 1]) || $v[count($v) - 1]['referendum'] != $row['referendum']) {
             $v[] = $row;
         } else {
             if (!isset($v[count($v) - 1]['subrows'])) {
                 $v[count($v) - 1]['subrows'] = array($v[count($v) - 1]);
             }
             $v[count($v) - 1]['subrows'][] = $row;
         }
     }
     return array('len' => $len, 'referendums' => $v);
 }
Example #7
0
function control()
{
    global $result, $input, $u_id;
    $conn = pg_connect("host=postgredb.ctnfr2pmdvmf.us-west-2.rds.amazonaws.com port=5432 dbname=postgreDB user=postgreuser password=6089qwerty");
    if (!$conn) {
        echo "denied An error occurred.\n";
        exit;
    }
    ini_set('date.timezone', 'America/Los_Angeles');
    $time = date('H:i:s', time());
    $date = date('Y-m-d') . " " . $time;
    $result = pg_query($conn, "SELECT FRIENDLISTID FROM FRIENDLIST WHERE USERID='{$u_id}' AND FRIENDID='{$input}'");
    $row = pg_fetch_row($result);
    if ($row[0]) {
        return "ALREADY A FRIEND";
    } else {
        if (pg_query($conn, "INSERT INTO FRIENDLIST ( USERID, FRIENDID,FRIENDLISTTIME) VALUES ('{$u_id}','{$input}',TIMESTAMP'{$date}')") == TRUE) {
            if (pg_query($conn, "INSERT INTO FRIENDLIST ( USERID, FRIENDID,FRIENDLISTTIME) VALUES ('{$input}','{$u_id}',TIMESTAMP'{$date}')") == TRUE) {
                return "New record created successfully";
            } else {
                return "denied. Only one way relationship inserted!";
            }
        } else {
            return "denied. Insertion query error!";
        }
    }
}
function getLastId($db)
{
    $last_uid = pg_query($db, "SELECT uid FROM uif ORDER BY uid DESC");
    $last_uid = pg_fetch_row($last_uid, 0);
    $last_uid = $last_uid[0];
    return $last_uid;
}
 /**
  * Get a row from the RecordSet.
  *
  * Case $row is set, return that row, case else, return the next row.
  *
  * @param int $row Row to return, defaults to next.
  * @param int $type Type of array to return (RS_ROW_NUM | RS_ROW_ASSOC | RS_ROW_BOTH).
  * @return array Returns the row from the RecordSet, or FALSE if EOF.
  */
 function Row($row = -1, $type = RS_ROW_ASSOC)
 {
     if ($row != -1) {
         $this->row = $row + 1;
         switch ($type) {
             case RS_ROW_NUM:
                 return pg_fetch_row($this->result, $this->row - 1);
                 break;
             case RS_ROW_ASSOC:
                 return pg_fetch_assoc($this->result, $this->row - 1);
                 break;
             case RS_ROW_BOTH:
                 return pg_fetch_array($this->result, $this->row - 1);
                 break;
         }
         return FALSE;
     }
     $this->row++;
     switch ($type) {
         case RS_ROW_NUM:
             return pg_fetch_row($this->result);
             break;
         case RS_ROW_ASSOC:
             return pg_fetch_assoc($this->result);
             break;
         case RS_ROW_BOTH:
             return pg_fetch_array($this->result);
             break;
     }
     return FALSE;
 }
Example #10
0
function postgis_query($string, $pgc = NULL)
{
    $pgct = $pgc;
    if ($pgc == NULL) {
        $pgct = postgis_connect();
    }
    @($result = pg_query($pgct, $string));
    if ($pgc == NULL) {
        pg_close($pgct);
    }
    $retval = array();
    if (!$result) {
        return $retval;
    }
    $arow = array();
    for ($i = 0; $i < pg_num_fields($result); $i++) {
        $arow[pg_field_name($result, $i)] = pg_field_type($result, $i);
    }
    $retval[0] = $arow;
    $ctr = 1;
    while ($row = pg_fetch_row($result)) {
        $arow = array();
        for ($i = 0; $i < count($row); $i++) {
            $arow[pg_field_name($result, $i)] = $row[$i];
        }
        $retval[$ctr] = $arow;
        $ctr++;
    }
    pg_free_result($result);
    return $retval;
}
Example #11
0
 public function value()
 {
     if ($row = pg_fetch_row($this->result, 0)) {
         return $row[0];
     }
     return false;
 }
Example #12
0
 public function Check($uid = 0)
 {
     $sql = "SELECT uid FROM birthday08 WHERE uid='" . $uid . "'";
     $res = pg_query(DBConnect(), $sql);
     list($ch) = pg_fetch_row($res);
     return $ch;
 }
 /**
  * Generate our fancypants Query Exception
  * @param $error
  * @param $sql
  * @return Exception
  */
 public function __construct($resource, $sql, Debug $debug)
 {
     $this->sql = $sql;
     $this->sqlError = pg_last_error($resource);
     // get the search path and add to exception message
     try {
         $qSearchPath = pg_query($resource, "SHOW search_path");
         $searchPath = pg_fetch_row($qSearchPath);
         $this->sqlError .= "\nSEARCH_PATH IS '{$searchPath[0]}'";
     } catch (\Exception $e) {
     }
     // build the debugging events we plan to emit
     $events = [self::QUERY_ERROR];
     // Not exactly happy to be doing this manually. Not cool postgres. Not cool.
     // http://www.postgresql.org/docs/8.4/static/errcodes-appendix.htm
     if ($haveState = preg_match('/ERROR:\\s+([A-Z0-9]{5}):/', $this->sqlError, $matches)) {
         $this->state = $matches[1];
         for ($i = 5; $i > 0; $i--) {
             $events[] = str_pad(substr($this->state, 0, $i), 5, '0');
         }
     } else {
         $this->state = 'EMPTY';
     }
     // emit out events
     foreach ($events as $eventName) {
         $debug->emit($eventName, $this->sql, $this->sqlError, $this->state);
     }
 }
Example #14
0
function getNextLogId()
{
    $qry = "select nextval('techmatcher.subscriptiontransactionlog_sq')";
    $result = pg_query($qry);
    $value = pg_fetch_row($result);
    return $value;
}
Example #15
0
 public function listing()
 {
     for ($list = array(); $row = pg_fetch_row($this->result); $list[] = $row[0]) {
     }
     $this->free();
     return $list;
 }
Example #16
0
 public function view()
 {
     session_start();
     // load trending items
     include 'models/itemModel.php';
     $itemModel = new itemModel();
     $trendingItemArray = array();
     $result = $itemModel->getTrendingItemList();
     for ($i = 0; $i < 5; $i++) {
         $row = pg_fetch_row($result);
         $item = array($row[0], $row[1], $row[2], $row[3]);
         // [0]: item name, [1]: owner name, [2]: price, [3]: image url
         array_push($trendingItemArray, $item);
     }
     /*
     		$itemModel = new itemModel();
     		$result = $itemModel->getItemKeyByMostLoanrequest();
     		$trendingItemIdArray = pg_fetch_all($result);
     
     		$trendingItemArray = [];
     		for ($i = 0; $i < 5; $i++) {
     			$result = $itemModel->getByKey($trendingItemIdArray[$i]["owner"], $trendingItemIdArray[$i]["item_name"]);
     			$trendingItemArray[] = pg_fetch_array($result);
     		}
     */
     // load view
     include 'views/home.php';
 }
function control()
{
    global $result, $input, $userID;
    $conn = pg_connect("host=postgredb.ctnfr2pmdvmf.us-west-2.rds.amazonaws.com port=5432 dbname=postgreDB user=postgreuser password=6089qwerty");
    if (!$conn) {
        echo "denied, an error occurred about connection.\n";
        exit;
    }
    $query = "SELECT USERNAME,USERID FROM PALUSER WHERE USERNAME LIKE '{$input}%' AND USERID != '{$userID}'";
    $result = pg_query($conn, $query);
    if (!$result) {
        echo "denied, an error occurred about query.\n";
        return 0;
    }
    $names = "";
    $ids = "";
    $first = true;
    while ($row = pg_fetch_row($result)) {
        if ($first) {
            $names = $row[0];
            $ids = $row[1];
            $first = false;
        } else {
            $names = $names . " " . $row[0];
            $ids = $ids . " " . $row[1];
        }
    }
    if ($ids == "") {
        echo "denied, empty result";
    }
    return $names . " " . $ids;
}
Example #18
0
function check_login()
{
    // If session does not exist on server side, or IP address has changed, or session has expired, show login screen.
    if (!isset($_SESSION['uid']) || !$_SESSION['uid'] || $_SESSION['ip'] != allIPs() || time() >= $_SESSION['expires_on']) {
        logout();
    }
    $_SESSION['expires_on'] = time() + INACTIVITY_TIMEOUT;
    // User accessed a page : Update his/her session expiration date.
    // Tracabilité LOG
    $dbconn = pg_connect(CONFIG_DB) or die('Connexion impossible : ' . pg_last_error());
    $numero_ID = $_SESSION['numero_abo'];
    if ($_SESSION['username'] != 'beprev') {
        $today = new DateTime('now');
        $horodate = date_format($today, 'Y-m-d H:i:s');
        $req = 'SELECT MAX("ID") from user_log;';
        $result = pg_query($req) or die('Échec de la requête : ' . pg_last_error());
        $table = pg_fetch_row($result);
        $Id = $table[0];
        if (strlen($Id) == 0) {
            $Id = 0;
        }
        $Id = $Id + 1;
        $page = $_SESSION["ipFrontOffice"] . $_SERVER['PHP_SELF'];
        $req = "INSERT INTO user_log (\"ID\", id_user,page,horodate) VALUES ('{$Id}','{$numero_ID}','{$page}','{$horodate}');";
        $result = pg_query($req) or die('Échec de la requête : ' . pg_last_error());
    }
    pg_close($dbconn);
}
Example #19
0
function check_serviceprovider_unlocked($id)
{
    $query = "select record_locked from techmatcher.serviceprovider where serviceprovider_id = \$1";
    $result = pg_query_params($query, array($id));
    $value = pg_fetch_row($result);
    return $value;
}
Example #20
0
function companyNameValidate($company)
{
    if (strlen($company) >= 2) {
        echo "{$company}";
        $query = "Select * from empresas where nombre='{$company}'";
        $result = pg_query($GLOBALS["conn"], $query);
        $row = pg_fetch_row($result);
        $GLOBALS['rowEmpresa'] = $row;
        if ($row[0] === NULL) {
            $query = "insert into empresas(nombre) values('{$company}');";
            $result = pg_query($GLOBALS["conn"], $query);
            $query1 = "select * empresas where nombre = '{$company}';";
            $result1 = pg_query($GLOBALS["conn"], $query1);
            $rowE = pg_fetch_row($result1);
            $GLOBALS['rowEmpresa'] = $rowE;
        }
        $p = $GLOBALS["rowUser"][0];
        $e = $GLOBALS['rowEmpresa'][0];
        $query2 = "insert into persona_empresa(idPersona, idEmpresa) values({$p},{$e});";
        $result2 = pg_query($GLOBALS["conn"], $query2);
        return array('state' => "Correcto", 'box' => "#box-company-profile");
    } else {
        $GLOBALS["estado"] = 1;
        return array('state' => "Incorrecto", 'box' => "#box-company-profile", 'errorBox' => "#error-company-profile", 'error' => "Debe tener al menos 2 caracteres.");
    }
}
function prepare_report($shemaid)
{
    $fname = tempnam("/tmp", "twrep");
    //$report_fname=$client_dir."/".$fname.".csv";
    $fw = fopen($fname, "w");
    fputs($fw, "ts,location,userid,rtc,placecntry,placename\n");
    $row = pg_fetch_row(pg_query("select t_id from scheme where id={$shemaid}"));
    $tag_id = (int) $row[0];
    $res = pg_query("select ts, location, userid, rtc, placecntry, placename from twits where t_id={$tag_id}");
    while ($row = @pg_fetch_assoc($res)) {
        // export row
        $line = array();
        $line[] = convert_to_cps_date($row["ts"]);
        $line[] = $row["location"];
        $line[] = $row["userid"];
        $line[] = $row["rtc"];
        $line[] = $row["placecntry"];
        $line[] = $row["placename"];
        fputcsv($fw, $line);
    }
    fclose($fw);
    $zip = new ZipArchive();
    $filename = "/tmp/twr" . $shemaid . ".zip";
    if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
        die("cant open <{$filename}>\n");
    }
    $zip->addFile($fname, "data.csv");
    $zip->close();
    @unlink($fname);
    return $filename;
}
Example #22
0
function control()
{
    global $conn, $result, $u_id;
    $conn = pg_connect("host=postgredb.ctnfr2pmdvmf.us-west-2.rds.amazonaws.com port=5432 dbname=postgreDB user=postgreuser password=6089qwerty");
    if (!$conn) {
        echo "An error occurred.\n";
        exit;
    }
    $result = pg_query($conn, "SELECT P.USERNAME,P.USERID FROM FRIENDLIST F,PALUSER P WHERE F.USERID='{$u_id}' AND P.USERID=F.FRIENDID");
    if (!$result) {
        echo "An error occurred about query.\n";
        return 0;
    }
    $names = "";
    $ids = "";
    $first = true;
    while ($row = pg_fetch_row($result)) {
        if ($first) {
            $sum = $row[0];
            $ids = $row[1];
            $first = false;
        } else {
            $sum = $sum . " " . $row[0];
            $ids = $ids . " " . $row[1];
        }
    }
    return $sum . " " . $ids;
}
Example #23
0
 function Header()
 {
     $this->AddFont('Amble-Regular');
     $this->SetFont('Amble-Regular', '', 10);
     $fecha = date('Y-m-d', time());
     $this->SetX(1);
     $this->SetY(1);
     $this->Cell(20, 5, $fecha, 0, 0, 'C', 0);
     $this->Cell(150, 5, "CLIENTE", 0, 1, 'R', 0);
     $this->SetFont('Arial', 'B', 16);
     $sql = pg_query("select ruc_empresa,nombre_empresa,propietario,telefono1,telefono2,direccion,correo,sitio_web,autorizacion_factura,autorizacion_factura,imagen from empresa where id_empresa = '" . $_SESSION['empresa_dow'] . "'");
     while ($row = pg_fetch_row($sql)) {
         $this->Cell(190, 8, maxCaracter("EMPRESA: " . utf8_decode($row[1]), 50), 0, 1, 'C', 0);
         $this->Image('../empresa/img/' . $row[10], 5, 8, 40, 30);
         $this->SetFont('Amble-Regular', '', 10);
         $this->Cell(180, 5, maxCaracter("PROPIETARIO: " . utf8_decode($row[2]), 50), 0, 1, 'C', 0);
         $this->Cell(70, 5, maxCaracter("TEL.: " . utf8_decode($row[3]), 50), 0, 0, 'R', 0);
         $this->Cell(60, 5, maxCaracter("CEL.: " . utf8_decode($row[4]), 50), 0, 1, 'C', 0);
         $this->Cell(170, 5, maxCaracter("DIR.: " . utf8_decode($row[5]), 55), 0, 1, 'C', 0);
         $this->Cell(170, 5, maxCaracter("E-MAIL.: " . utf8_decode($row[6]), 55), 0, 1, 'C', 0);
         $this->Cell(170, 5, maxCaracter("SITIO WEB.: " . utf8_decode($row[7]), 55), 0, 1, 'C', 0);
         $this->Text(160, 30, maxCaracter("Nro Aut SRI.: " . utf8_decode($row[8]), 55), 0, 1, 'C', 0);
         $this->Text(150, 35, maxCaracter("Fecha Aut SRI.: " . utf8_decode($row[9]), 55), 0, 1, 'C', 0);
         $this->Text(70, 44, "OBLIGADO A LLEVAR CONTABILIDAD : SI", 0, 'C', 0);
         $this->SetFont('Amble-Regular', 'U', 14);
         $this->Text(85, 49, "LIBRO DIARIO", 0, 'C', 0);
         $this->Text(85, 49, "LIBRO DIARIO", 0, 'C', 0);
     }
     $this->SetDrawColor(0, 0, 0);
     $this->SetLineWidth(0.5);
     $this->Line(1, 53, 210, 53);
     $this->Ln(16);
 }
Example #24
0
	/**
	* Report a comment as a spam.
	* @param string $comid Comment ID
	* @param string $revid Revision ID of the comment
	* @param integer $uid User ID of person who reported spam.
	* @return integer Spam return ID
	*/
	public static function report($comid, $revid, $uid)
	{
		$sql = "Insert into comment_spam(sp_comid,sp_revid,sp_uid) values('$comid','$revid','$uid') returning sp_id";
		$row=pg_fetch_row(dbquery($sql));
		return $row[0];
		
	}
 public function Afficher()
 {
     // - On se connecte à la base de données
     parent::ConnecterBD();
     // - on récupère des infos de la session
     $account_id = $_SESSION['account_id'];
     // - on récupère les infos de l'url
     $type = "";
     if (!isset($_GET['type'])) {
         $type = "current";
     } else {
         $type = $_GET['type'];
     }
     $_SESSION['quete_type'] = $type;
     // - Parcours des messages
     $_SESSION['quete_titre'] = array();
     $_SESSION['quete_coord_x'] = array();
     $_SESSION['quete_coord_y'] = array();
     $_SESSION['quete_recompense'] = array();
     $_SESSION['quete_is_read'] = array();
     // - On récupère les données
     $sql = "SELECT quete_id, is_read, titre, coord_x, coord_y, recompense FROM \"libertribes\".\"QUETE\" WHERE account_id = {$account_id} and type = '{$type}'";
     $result = parent::Requete($sql);
     if ($result) {
         $iCpt = 0;
         while ($row = pg_fetch_row($result)) {
             // - on stocke les messages
             $_SESSION['quete_id'][$iCpt] = $row[0];
             $_SESSION['quete_is_read'][$iCpt] = $row[1];
             $_SESSION['quete_titre'][$iCpt] = $row[2];
             $_SESSION['quete_coord_x'][$iCpt] = $row[3];
             $_SESSION['quete_coord_y'][$iCpt] = $row[4];
             $_SESSION['quete_recompense'][$iCpt] = $row[5];
             $iCpt++;
         }
         $_SESSION['quete_compteur'] = $iCpt;
     }
     // - Gestion du nb de pages
     $iNbPages = ceil($_SESSION['quete_compteur'] / 5);
     if ($iNbPages == 0) {
         $iNbPages = 1;
     }
     $_SESSION['quete_nb_pages'] = $iNbPages;
     // - Gestion du no de page
     if (!isset($_POST['quete_no_page'])) {
         $_SESSION['quete_no_page'] = 1;
     } else {
         $iPage = $_POST['quete_no_page'];
         if ($iPage < 0) {
             $iPage = 1;
         }
         if ($iPage > $iNbPages) {
             $iPage = $iNbPages;
         }
         $_SESSION['quete_no_page'] = $iPage;
     }
     parent::Afficher();
     // - gestion spécifique de la page
 }
Example #26
0
 function RepStandard()
 {
     // First Generate the query
     $sq = $this->RepStandardQuery();
     if ($this->display == 'SQL') {
         echo "<h1>The Generated SQL</h1>";
         hprint_r($sq);
         return;
     }
     // Now execute the query and run the report
     if ($this->display == 'CSV') {
         echo "<pre>";
         echo implode(',', $this->Cols) . "\n";
         $res = SQL($sq);
         while ($row = pg_fetch_row($res)) {
             echo implode(',', $row) . "\n";
         }
         echo "</pre>";
         return;
     }
     // Pull the info on breaking, sums, etc.
     $srep = SQLFC($this->report_id);
     $s2 = "SELECT rcl.column_id,rcl.reportlevel,rcl.summact\n             FROM reportcollevels rcl\n             JOIN reportcolumns   rc  ON rcl.column_id = rc.column_id\n            WHERE rc.report = {$srep}\n            ORDER BY rcl.reportlevel,rc.uicolseq";
     $breaks = SQL_AllRows($s2);
     $abreaks = array();
     foreach ($breaks as $break) {
         if ($break['summact'] == 'BREAK') {
             $abreaks[$break['reportlevel']]['breaks'][$break['column_id']] = '';
         } else {
             $abreaks[$break['reportlevel']]['data'][$break['column_id']] = array('summact' => $break['summact'], 'val' => 0, 'cnt' => 0);
         }
     }
     // There is always some setup, for either PDF or HTML, so do that
     // here.
     $this->RepHeader();
     // Now execute the query and run the report
     $res = SQL($sq);
     $firstrow = true;
     while ($row = SQL_Fetch_Array($res)) {
         if ($firstrow) {
             $firstrow = false;
             $this->RepStandardBreakLevelsInit($abreaks, $row);
         } else {
             $this->RepStandardBreakLevels($abreaks, $row);
         }
         $xpos = 0;
         foreach ($this->rows_col as $column_id => $colinfo) {
             $disp = substr($row[$column_id], 0, $colinfo['dispsize']);
             $disp = STR_PAD($disp, $colinfo['dispsize'], ' ');
             $this->PlaceCell($xpos, $disp);
             $xpos += 2 + $colinfo['dispsize'];
         }
         $this->ehFlushLine();
         $this->RepStandardRowsToLevels($abreaks, $row);
     }
     $this->RepStandardBreakLevels($abreaks, $row, true);
     // There is always some cleanup, either PDF or HTML
     $this->RepFooter();
 }
Example #27
0
 function Header()
 {
     $this->AddFont('Amble-Regular', '', 'Amble-Regular.php');
     $this->SetFont('Amble-Regular', '', 10);
     $fecha = date('Y-m-d', time());
     $this->SetX(1);
     $this->SetY(1);
     $this->Cell(20, 5, $fecha, 0, 0, 'C', 0);
     $this->Cell(170, 5, "CLIENTE", 0, 1, 'R', 0);
     $this->SetFont('Arial', 'B', 16);
     $this->Cell(190, 8, "EMPRESA: " . $_SESSION['empresa'], 0, 1, 'C', 0);
     $this->Image('../images/logo_empresa.jpg', 5, 8, 45, 30);
     $this->SetFont('Amble-Regular', '', 10);
     $this->Cell(190, 5, "PROPIETARIO: " . utf8_decode($_SESSION['propietario']), 0, 1, 'C', 0);
     $this->Cell(80, 5, "TEL.: " . utf8_decode($_SESSION['telefono']), 0, 0, 'R', 0);
     $this->Cell(80, 5, "CEL.: " . utf8_decode($_SESSION['celular']), 0, 1, 'C', 0);
     $this->Cell(180, 5, "DIR.: " . utf8_decode($_SESSION['direccion']), 0, 1, 'C', 0);
     $this->Cell(180, 5, "SLOGAN.: " . utf8_decode($_SESSION['slogan']), 0, 1, 'C', 0);
     $this->Cell(180, 5, utf8_decode($_SESSION['pais_ciudad']), 0, 1, 'C', 0);
     $this->SetDrawColor(0, 0, 0);
     $this->SetLineWidth(0.4);
     $this->SetFillColor(120, 120, 120);
     $this->Line(1, 60, 210, 60);
     $this->Line(1, 45, 210, 45);
     $this->SetFont('Arial', 'B', 12);
     $this->Cell(190, 5, utf8_decode("KARDEX DE PRODUCTOS"), 0, 1, 'C', 0);
     $this->SetFont('Amble-Regular', '', 10);
     $this->Ln(2);
     $this->SetFillColor(255, 255, 225);
     if ($_GET['id'] == "") {
         $this->SetX(1);
         $this->Cell(85, 6, utf8_decode('Desde el: ' . $_GET['inicio']), 0, 0, 'L', 1);
         $this->Cell(120, 6, utf8_decode('Hasta el: ' . $_GET['fin']), 0, 1, 'L', 1);
         $this->SetX(1);
         $this->Cell(85, 6, utf8_decode('Código: '), 0, 0, 'L', 1);
         $this->Cell(120, 6, utf8_decode('Descripción: '), 0, 1, 'L', 1);
     } else {
         $sql = pg_query("select P.codigo, P.articulo from productos P where P.cod_productos = '{$_GET['id']}'");
         $this->SetLineWidth(0.2);
         while ($row = pg_fetch_row($sql)) {
             $this->SetX(1);
             $this->Cell(85, 6, utf8_decode('Desde el: ' . $_GET['inicio']), 0, 0, 'L', 1);
             $this->Cell(120, 6, utf8_decode('Hasta el: ' . $_GET['fin']), 0, 1, 'L', 1);
             $this->SetX(1);
             $this->Cell(85, 6, utf8_decode('Código: ' . $row[0]), 0, 0, 'L', 1);
             $this->Cell(120, 6, utf8_decode('Descripción: ' . $row[1]), 0, 1, 'L', 1);
         }
     }
     $this->Ln(5);
     $this->SetX(1);
     $this->SetFont('Amble-Regular', '', 10);
     $this->Cell(53, 5, utf8_decode("Transacción"), 1, 0, 'C', 0);
     $this->Cell(40, 5, utf8_decode("Origen"), 1, 0, 'C', 0);
     $this->Cell(40, 5, utf8_decode("Destino"), 1, 0, 'C', 0);
     $this->Cell(25, 5, utf8_decode("Fecha"), 1, 0, 'C', 0);
     $this->Cell(25, 5, utf8_decode("Movimiento"), 1, 0, 'C', 0);
     $this->Cell(25, 5, utf8_decode("Stock"), 1, 0, 'C', 0);
     $this->Ln(5);
 }
Example #28
0
function getUserName($id)
{
    $sql = pg_prepare(getDatabaseConnection(), "getUserName", "SELECT username FROM users WHERE id =\$1;");
    $result = pg_execute(getDatabaseConnection(), "getUserName", [$id]) or die('Query failed: ' . pg_last_error());
    $row = pg_fetch_row($result);
    pg_close(getDatabaseConnection());
    return $row[0];
}
 protected function _getLastInsertId($queryId)
 {
     $row = pg_fetch_row($queryId);
     pg_free_result($queryId);
     if (is_array($row)) {
         return $row[0];
     }
 }
Example #30
0
function sql_row($r, $i)
{
    if ($i >= pg_num_rows($r)) {
        pg_free_result($r);
        return 0;
    }
    return pg_fetch_row($r, $i);
}