function entradaBitacoraEmp($iduser, $elemento, $texto, $idemp)
 {
     $con = new Database();
     $sql = "insert into bitacora(usuario,elemento_afectado,accion_realizada) values ({$iduser},'{$elemento}','{$texto}')";
     $con->Query($sql);
     $idbit = $con->LastInsertID();
     $sql = "insert into rel_bitacora_empleados(id_bitacora,id_expediente) values ({$idbit},{$idemp} )";
     $con->Query($sql);
 }
 function updateEmpleado($datos)
 {
     $con = new Database();
     $sql = "update empleados set nombre='" . $datos['nombres'] . "', apd_paterno='" . $datos['a_pat'] . "', apd_materno='" . $datos['a_mat'] . "', telefono='" . $datos['telefono'] . "', \n\t\tcorreo_electronico='" . $datos['email'] . "', puesto='" . $datos['cargo'] . "', rfc='" . $datos['rfc'] . "', curp='" . $datos['curp'] . "', \n\t\tstatus=" . $datos['status'] . ", nacionalidad='" . $datos['nacionalidad'] . "', ife='" . $datos['ife'] . "', fecha_nac='" . $datos['fnac'] . "',\n \t\tgiro='" . $datos['giro'] . "', participacion='" . $datos['participacion'] . "' where id_empleado=" . $datos['id_empleado'];
     $con->Query($sql);
     $idem = $con->LastInsertID();
     $sqldom = "update domicilios set calle='" . $datos['calle'] . "', via='" . $datos['avenida'] . "', num='" . $datos['n_ext'] . "', num_int='" . $datos['n_int'] . "', \n\t\tcol='" . $datos['col'] . "', cp='" . $datos['cp'] . "', ciudad='" . $datos['ciudad'] . "', estado='" . $datos['estado'] . "',\n \t\tdelegacion='" . $datos['delegacion'] . "', pais='" . $datos['pais'] . "' where id_dom=" . $datos['id_dom'];
     $con->Query($sqldom);
     $idDom = $con->LastInsertID();
 }
 function getUdi()
 {
     $con = new Database();
     $sql = "select  u.valor , max(u.fecha_captura) from valor_udi as u limit 1";
     $con->Query($sql);
     return $con;
 }
 function listaProductos()
 {
     $con = new Database();
     $sql = "select * from productos";
     $con->Query($sql);
     return $con;
 }
 function listaExpedientesCliente()
 {
     $con = new Database();
     $query = "select cl.id_cliente,cl.razon,cl.a_pat,cl.a_mat,cl.nombre,cl.rfc,cl.curp\n\t\t\t\t\tfrom clientes_todos as cl,tipo_expedientes as tp, main_tipos_expedientes as ma where cl.tipo_exp = tp.id_tipo_expedientes\n\t\t\t\t\tand tp.id_main = ma.id and ma.id <= 4 order by cl.nombre,cl.razon";
     $con->Query($query);
     return $con;
 }
Example #6
0
 public static function SumDonations($NumDays = 10000)
 {
     $Time = time() - $NumDays * 86400;
     $QueryRes = Database::Query("SELECT SUM(Amount) FROM " . self::$TableName . " WHERE Date > {$Time};")->fetch_assoc();
     $TotalDonated = isset($QueryRes["SUM(Amount)"]) ? intval($QueryRes["SUM(Amount)"]) : 0;
     return $TotalDonated;
 }
 public function cargarMenu($idUsuario)
 {
     $query = "Select md.nombre, md.ruta, m.nombre as menu, m.idMenu from tblusuariopermisos as up join \n                tblmenudetalle as md on up.idPermiso = md.idMenuDetalle\n                join tblmenu as m on m.idMenu = md.idMenu\n                WHERE up.idUsuario = {$idUsuario}\n                order by m.idMenu, md.orden";
     $con = new Database();
     $con->Query($query);
     return $con;
 }
 function updateNotificacionManualAutomatica()
 {
     include_once '../controller/cUtilerias.php';
     $cUtilerias = new cUtilerias();
     $fecha = $cUtilerias->getDate();
     $fecha_inicio = strtotime('-1 month', strtotime($fecha));
     $fecha_inicio = date('Y-m-d', $fecha_inicio);
     $fecha_fin = strtotime('-7 day', strtotime($fecha));
     $fecha_fin = date('Y-m-d', $fecha_fin);
     $sql = "update notificacionpersonalizada set estatus=-1 where fecha_fin BETWEEN '{$fecha_inicio}' and '{$fecha_fin}';";
     //actualizamos las notificaciones que se encuentren en su fecha limite o ya la pasaron las desactivamos
     // echo $sql;
     $this->con->Query($sql);
     //recuperamos las notificaciones que se encuentren con repeticion y ya pasaron
     $sql = "select n.id_notificacion,n.repeticion,n.fecha_cambio,n.tiempo_repetir from notificacionpersonalizada as n where n.repeticion!=-1 and n.fecha_cambio BETWEEN '{$fecha_inicio}' and '{$fecha_fin}';";
     // echo $sql;
     $this->con->Query($sql);
     $datos = $this->con;
     include_once "../model/mConexion.php";
     $DB = new Database();
     while ($row = $datos->NextRow()) {
         $tipo_repeticion = $row['repeticion'];
         $fecha_cambio = $row['fecha_cambio'];
         $tiempo_repetir = $row['tiempo_repetir'];
         $id_notificacion = $row['id_notificacion'];
         $nueva_fecha_cambio = $this->getRepeticion($tipo_repeticion, $fecha_cambio, $tiempo_repetir);
         $sql = "update notificacionpersonalizada set fecha_cambio='{$nueva_fecha_cambio}' where id_notificacion={$id_notificacion};";
         $DB->Query($sql);
         // echo $sql;
     }
 }
 /**
  * Executes $query against database and returns the result set as an array of POG objects
  *
  * @param string $query. SQL query to execute against database
  * @param string $objectClass. POG Object type to return
  * @param bool $lazy. If true, will also load all children/sibling
  */
 function FetchObjects($query, $objectClass, $lazy = true)
 {
     $databaseConnection = Database::Connect();
     $result = Database::Query($query, $databaseConnection);
     $objectList = $this->CreateObjects($result, $objectClass, $lazy);
     return $objectList;
 }
Example #10
0
 static function Insert($TableName, $Data)
 {
     $InsertQuery = "INSERT INTO `{$TableName}` (";
     $Incrementer = 0;
     foreach ($Data as $Key => $Value) {
         $Incrementer++;
         $InsertQuery .= "`" . $Key . "` ";
         if (count($Data) > $Incrementer) {
             $InsertQuery .= ",";
         }
     }
     $InsertQuery .= ") VALUES (";
     $Incrementer = 0;
     foreach ($Data as $Key => $Value) {
         $Incrementer++;
         if (is_numeric($Value)) {
             $InsertQuery .= $Value;
         } else {
             $InsertQuery .= "'" . Database::Escape($Value) . "'";
         }
         if (count($Data) > $Incrementer) {
             $InsertQuery .= ",";
         }
     }
     $InsertQuery .= ");";
     Database::Query($InsertQuery);
 }
 public function changeDolar()
 {
     $con = new Database();
     $query = "insert into valor_dolar_mn(valor) values(" . $_POST['valor'] . ")";
     $con->Query($query);
     echo "\$" . $_POST['valor'];
 }
 function carteraVencida()
 {
     $con = new Database();
     $query = "select con.id_contrato, ct.nombre, ct.a_pat, ct.a_mat,\n\n (select pagos_clte.fecha_pago from pagos_clte,tabla_amortizacion where exists\n  (select * from pagos_clte,tabla_amortizacion where pagos_clte.id_tabla_amort = tabla_amortizacion.asiento)\n  and pagos_clte.id_tabla_amort  = tabla_amortizacion.asiento order by\n pagos_clte.fecha_pago desc limit 1) as fecha_pago_ultimo,\n\n  (select concat(tabla_amortizacion.id_contrato,'-',tabla_amortizacion.n_pago) from tabla_amortizacion,pagos_clte where\n pagos_clte.id_tabla_amort = tabla_amortizacion.asiento and  tabla_amortizacion.id_contrato = con.id_contrato order by\n pagos_clte.fecha_pago desc limit 1 ) as ref_ultimo_pago, tb.saldo_insoluto,\n (select concat(tabla_amortizacion.id_contrato,'-',tabla_amortizacion.n_pago)\n from tabla_amortizacion where tabla_amortizacion.id_contrato = con.id_contrato\n  and not exists(select * from pagos_clte where pagos_clte.id_tabla_amort = tabla_amortizacion.asiento)\n   order by tabla_amortizacion.fecha_corte asc limit 1) as f_pago_atrasado\n  from contratos as con, clientes_todos as ct, tabla_amortizacion as tb\nwhere ct.id_cliente = con.id_clte and tb.id_contrato = con.id_contrato and not exists (select pagos_clte.id_tabla_amort from\npagos_clte where pagos_clte.id_tabla_amort = tb.asiento) and con.vigente > 0 and tb.fecha_corte <= CURRENT_DATE() group by con.id_contrato";
     $con->Query($query);
     return $con;
 }
Example #13
0
 public static function RegisterUser($SteamID, $IP)
 {
     $AuthHash = md5(rand()) . md5(rand());
     $SteamID = Database::Escape($SteamID);
     $IP = Database::Escape($IP);
     Database::Query("INSERT INTO `gmd_users` VALUES (NULL, '%s', '%s', '%s', 0, 0.0);", $AuthHash, $SteamID, $IP);
     return User::GetByField("User", "SteamID", $SteamID);
 }
 /**
  * Physically saves the mapping to the database
  * @return 
  */
 function Save()
 {
     $connection = Database::Connect();
     $this->pog_query = "select `objectid` from `objectsiblingmap` where `objectid`='" . $this->objectId . "' AND `siblingid`='" . $this->siblingId . "' LIMIT 1";
     $rows = Database::Query($this->pog_query, $connection);
     if ($rows == 0) {
         $this->pog_query = "insert into `objectsiblingmap` (`objectid`, `siblingid`) values ('" . $this->objectId . "', '" . $this->siblingId . "')";
     }
     return Database::InsertOrUpdate($this->pog_query, $connection);
 }
 function coincidenciasClte($razon, $nombre, $a_pat, $a_mat)
 {
     $con = new Database();
     if ($razon == '') {
         $query = "select distinct cl.clave_agrupadora,cl.razon,cl.nombre,cl.a_mat,cl.a_pat,mn.nombre as tipo_expe\n \t\t\t\tfrom clientes_todos as cl, main_tipos_expedientes as mn, tipo_expedientes as te\n \t\t\t\twhere cl.tipo_exp = te.id_tipo_expedientes and te.id_main = mn.id and\n\t\t\t\t(cl.nombre like '%{$nombre}%' or cl.a_pat like '%{$a_pat}%' or cl.a_mat like '%{$a_mat}%') ";
     } else {
         $query = "select distinct * from clientes_todos where razon like '%{$razon}%' ";
     }
     $con->Query($query);
     return $con;
 }
 function On_Editor_SaveModuleFragmentObject($a_data)
 {
     $object = $a_data->object;
     // Save if we have such a plugin
     if ($plugin = $this->m_pluginmgr->GetPlugin($object['type'])) {
         Database::Query("INSERT INTO `" . DB_TBL_DATA . "` (`type`, `name`, `owner`, `moduleid`) VALUES ('string', '" . $object['name'] . "', '" . $a_data->owner . "', '" . $a_data->moduleid . "')");
         $id = Database::GetLastIncrId();
         $a_data->data_id = $id;
         $plugin->SaveObject($a_data);
     }
 }
 public static function Initialize()
 {
     // Database
     Database::Initialize();
     Database::Query("SET NAMES UTF8");
     // Locales
     Locales::Initialize();
     // Acount
     self::$m_account = new Account();
     // Plugins
     self::$m_pluginmgr = new PluginMgr(PLUGIN_DIR);
 }
 function On_Editor_SaveModuleFragmentObject($a_data)
 {
     $object = $a_data->object;
     // Save
     if ($object['type'] == "iterator" && $object['childs']) {
         foreach ($object['childs'] as $childs) {
             Database::Query("INSERT INTO `" . DB_TBL_DATA . "` (`type`, `name`, `owner`, `moduleid`) VALUES ('itr', '" . $object['name'] . "', '" . $a_data->owner . "', '" . $a_data->moduleid . "')");
             $id = Database::GetLastIncrId();
             Editor::SaveModuleFragment($childs, -$id);
         }
     }
 }
Example #19
0
function execute($cronjob)
{
    ob_start();
    // Start output caching
    require CRONJOB_DIR . $cronjob['path'] . '.php';
    // Require cronjob
    ob_end_clean();
    // Omit cached output
    Lightwork::Log('Cronjob executed: ' . $cronjob['name']);
    // Log success
    Database::Query(LWC::QUERY_CRONJOB_UPDATE, [':id', $cronjob['id'], PDO::PARAM_INT]);
    // Update timestamp in database
}
 /**
  *
  * @access public
  * @static
  * @param Rate $obj
  * @return Rate|false
  */
 public static function Add($obj)
 {
     $cmd = sprintf("INSERT INTO zi_rates (user_id,idea_id) VALUES(%d,%d)", $obj->user_id, $obj->idea_id);
     try {
         if (!Database::Query($cmd, false)) {
             throw new RateException("can't add rate");
         }
         $obj->rate_id = Database::GetLastInsertId();
     } catch (Exception $e) {
         Debug::Log($e, ERROR);
         return false;
     }
     return $obj;
 }
 /**
  *
  * @access public
  * @static
  * @param Idea $idea
  * @return integer|false
  */
 public static function GetCountByIdea($idea)
 {
     $cmd = sprintf("SELECT count(comment_id) AS comments_count FROM zi_comments WHERE idea_id=%d", $idea->idea_id);
     try {
         $data = Database::Query($cmd);
         if (empty($data)) {
             throw new IdeaException("can't get comments count for idea");
         }
     } catch (Exception $e) {
         Debug::Log($e, ERROR);
         return false;
     }
     return $data[0]["comments_count"];
 }
 /**
  * LOGIN
  */
 static function Login($credentials)
 {
     $query = '
         SELECT id, first_name, last_name, accountant
         FROM representative
         WHERE login = :login AND password = :password
     ';
     $result = Database::Query($query, ['login' => $credentials['login'], 'password' => $credentials['password']]);
     if (!empty($result['id'])) {
         Session::Set('id', $result['id']);
         Session::Set('first_name', $result['first_name']);
         Session::Set('last_name', $result['last_name']);
         Session::Set('accountant', $result['accountant']);
         header('Location: http://' . DOMAIN . '/home/display');
     }
 }
Example #23
0
 public function Delete()
 {
     $ItemActions = ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID"));
     // Delete all actions related to this item
     foreach ($ItemActions as $ItemAction) {
         // Delete all of the user actions using this Item Action
         $UserActions = UserAction::GetAllByField("UserAction", "ItemAction", $ItemAction->GetValue("ID"));
         foreach ($UserActions as $UserAction) {
             $UserAction->Delete();
         }
         // Delete the actual item action
         $ItemAction->Delete();
     }
     // Delete the saved image (we warned them)
     $this->DeleteImage();
     // Literally delete the item itself
     Database::Query("DELETE FROM `%s` WHERE `ID` = %s;", static::$TableName, $this->Data["ID"]);
     DB_Accessor::FlushMemCache(get_class($this));
 }
 function getPersona($id_persona)
 {
     $con = new Database();
     $con->Query("select nombre,paterno,materno,curp,fecha_nacimiento from personas where id_persona=" . $id_persona);
     $nombe = "";
     $paterno = "";
     $materno = "";
     $curp = "";
     $fecha = "";
     while ($fila = $con->nextRow()) {
         $fecha = strtotime($fila['fecha_nacimiento']);
         $paterno = $fila['paterno'];
         $materno = $fila['materno'];
         $nombre = $fila['nombre'];
         $curp = $fila['curp'];
         $fecha = date('d-m-Y', $fecha);
     }
     $array = array("nombre" => $nombre, "paterno" => $paterno, "materno" => $materno, "curp" => $curp, "fecha" => $fecha);
     return $array;
 }
 /**
  *  function to not repeating same code in every method
  *  $query   sql query
  *  $message  message throwed by exception
  *  @access private
  *  @static
  *  @return Ideas|false
  */
 private static function GetCollectionData($query, $message = "error while getting ideas")
 {
     if (empty($query)) {
         return false;
     }
     $obj = new Ideas();
     try {
         $data = Database::Query($query);
         if (empty($data)) {
             throw new IdeasException($message);
         }
         foreach ($data as $row) {
             $obj->collection[] = Idea::GetById($row["idea_id"]);
         }
     } catch (Exception $e) {
         Debug::Log($e, WARNING);
         return false;
     }
     return $obj->collection;
 }
 public static function GetPage($a_id)
 {
     $id = Database::Escape($a_id);
     $result = Database::Query("SELECT * FROM `" . DB_TBL_PAGES . "` WHERE `id` = '" . $id . "'");
     if (!$result->HasData()) {
         die('Unknown page id');
     }
     self::$m_pagename = unserialize($result->GetValue('name'));
     $doc = unserialize($result->GetValue('compiled'));
     if (!$doc) {
         $compiler = new Compiler();
         $doc = $compiler->CompilePage($id);
     }
     // Plugin Hook
     $data_object = new stdClass();
     $data_object->doc = $doc;
     ObjMgr::GetPluginMgr()->ExecuteHook("On_PrepareTemplate", $data_object);
     // Title
     Content::AddTitle($doc, Locales::GetConstString("PAGE_TITLE", NULL, self::$m_pagename[Locales::$m_locale]));
     return $doc->getHtml();
 }
Example #27
0
 public function update()
 {
     if (!isset($this->data[$this->key_field]) || intval($this->data[$this->key_field]) < 1) {
         return false;
     }
     $id = $this->data[$this->key_field];
     unset($this->data[$this->key_field]);
     $array = $this->data;
     foreach ($array as $field => $value) {
         $update[] = "`" . $field . "` = :" . $field;
         $params[":" . $field] = $value;
     }
     $base = "UPDATE {$this->table_name} SET";
     $update = implode(",", $update);
     $params[":id"] = $id;
     $the_field = $this->key_field;
     $query = $base . " " . $update . " " . "WHERE {$the_field} = :id";
     Database::Query($query, $params);
     $this->loadByID($id);
     return true;
 }
        }
        if ($m == 00) {
            $b1 = $fyear - 543 - 3 . '-12-01';
            $b2 = $fyear - 543 - 3 . '-12-31';
        }
    }
}
//
$dbrpt = new Database(DB_HOST_TK, DB_USER_TK, DB_PASS_TK, DB_NAME_TK);
//new object
?>
<div class="panel panel-info">
<div class="panel-heading">
 <?php 
//select name report
$dbrpt->Query("SELECT * FROM z42_sys_report WHERE id='{$id}' ORDER BY cat_id");
while ($arrrpt = $dbrpt->Fetch_array()) {
    ?>
		<h4><?php 
    echo $arrrpt['report_name'];
    ?>
</h4>
		<?php 
}
if ($m == '') {
    ?>
	
<a href="javascript:history.go(-1)" class="btn btn-default btn-sm " role="button">Back</a>
<a href="../exportxls/child_develop_cid_export_excel.php?id=<?php 
    echo $id;
    ?>
 /**
  * Saves the object to the database
  * @return integer $parent_Id
  */
 function Save($deep = true)
 {
     $connection = Database::Connect();
     $this->pog_query = "select `parent_id` from `parent_` where `parent_id`='" . $this->parent_Id . "' LIMIT 1";
     $rows = Database::Query($this->pog_query, $connection);
     if ($rows > 0) {
         $this->pog_query = "update `parent_` set \n\t\t\t`attribute`='" . $this->Escape($this->attribute) . "' where `parent_id`='" . $this->parent_Id . "'";
     } else {
         $this->pog_query = "insert into `parent_` (`attribute` ) values (\n\t\t\t'" . $this->Escape($this->attribute) . "' )";
     }
     $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
     if ($this->parent_Id == "") {
         $this->parent_Id = $insertId;
     }
     if ($deep) {
         foreach ($this->_objectList as $object) {
             $object->parent_Id = $this->parent_Id;
             $object->Save($deep);
         }
     }
     return $this->parent_Id;
 }
             <th>ม.ค.</th>
             <th>ก.พ.</th>
             <th>มี.ค.</th>
             <th>ม.ย.</th>
             <th>พ.ค.</th>
             <th>มิ.ย.</th>
             <th>ก.ค.</th>
             <th>ส.ค.</th>
             <th>ก.ย.</th>-->
             
          </tr>
     </thead>
     <tbody>             
</tbody>
<?php 
$dbrpt->Query("\n SELECT \n        tb1.AMP_CODE as AMPCODE,\n        tb1.AMP_NAME as AMPNAME,\n        tb2.A AS A,\n        tb2.B AS B,\n        tb2.P AS P,\n        tb2.orange as orange,\n        tb2.red as red,\n        tb2.black as black\nFROM(\n     SELECT \n           AMP_CODE,AMP_NAME  \n            FROM z42_amp \n      GROUP BY AMP_CODE \n) as tb1\nLEFT JOIN\n(\n    SELECT \n        amp.AMP_NAME AS AMPNAME,left(areacode,4) as AMPCODE,\n        SUM(black) as A,\n        SUM(target) as B,\n        ROUND((sum(black)/sum(target))*100,2) as P,\n        SUM(orange) as orange,SUM(red)AS red,SUM(black)AS black\n        FROM z42_s_dm_color\n        LEFT OUTER JOIN z42_amp AS amp ON LEFT(z42_s_dm_color.areacode,4)=amp.AMP_CODE\n        WHERE b_year BETWEEN '{$o_year}' AND '{$b_year}' AND date_com BETWEEN '{$ystr}' AND '{$yend}' \n        GROUP BY LEFT(areacode,4)\n) as tb2 ON tb1.AMP_CODE=tb2.AMPCODE \nGROUP BY tb1.AMP_CODE \nUNION ALL\n     SELECT \n        'TOTAL' AS AMPNAME,'รวม' as AMPCODE,\n        SUM(black) as A,\n        SUM(target) as B,\n        ROUND((sum(black)/sum(target))*100,2) as P,\n        SUM(orange) as orange,SUM(red)AS red,SUM(black)AS black\n        FROM z42_s_dm_color\n        LEFT OUTER JOIN z42_amp AS amp ON LEFT(z42_s_dm_color.areacode,4)=amp.AMP_CODE\n        WHERE b_year BETWEEN '{$o_year}' AND '{$b_year}' AND date_com BETWEEN '{$ystr}' AND '{$yend}' ;\n  \n ");
while ($arr_rs = $dbrpt->Fetch_array()) {
    $ampcode = $arr_rs['AMPCODE'];
    ?>
    
	<tr>
       
		<td align="center">
         <a href="javascript:popup('dm_color_black_pcu.php?ampcode=<?php 
    echo $arr_rs['AMPCODE'];
    ?>
&id=<?php 
    echo $id;
    ?>
&b_year=<?php 
    echo $b_year;