Example #1
0
 function crearItemsDeCarga($id)
 {
     begin();
     if ($this->cargaExists($id)) {
         if (!$this->eliminarItemsDeCarga($id)) {
             rollback();
         }
     }
     $sql = "INSERT INTO cargas (id_reparto, id_producto, cantidad, fecha_update)\n                SELECT  t1.id_reparto, \n                        t4.id_producto,\n                        SUM(t3.cantidad_detalle_venta) cantidad,\n                        NOW()\n                FROM repartos t1\n                INNER JOIN ventas t2 ON t1.id_reparto=t2.id_reparto\n                INNER JOIN detalle_ventas t3 ON t2.id_venta=t3.id_venta\n                INNER JOIN productos t4 ON t3.id_producto=t4.id_producto\n                WHERE t1.id_reparto != 1 AND t1.id_reparto = {$id}\n                GROUP BY t4.id_producto\n                ORDER BY detalle_producto";
     if (!mysql_query($sql)) {
         die('Error: ' . mysql_error());
         rollback();
         return false;
     } else {
         commit();
         return true;
     }
 }
Example #2
0
function begin()
{
    echo "\r\n+------------------------\r\n| [ 1 ] 生成Model \r\n| [ 2 ] 生成Action  \r\n| [ 0 ] 退出\r\n+------------------------\r\n输入数字选择:";
    $number = trim(fgets(STDIN, 256));
    //fscanf(STDIN, "%d\n", $number); // 从 STDIN 读取数字
    switch ($number) {
        case 0:
            break;
        case 1:
            echo "输入Model名称[例如 User,留空生成当前数据库的全部Model类 ]:";
            $model = trim(fgets(STDIN, 256));
            if (strpos($model, ',')) {
                echo "批量生成Model...\n";
                $models = explode(',', $model);
                foreach ($models as $model) {
                    buildModel($model);
                }
            } else {
                // 生成指定的Model类
                buildModel($model);
            }
            begin();
            break;
        case 2:
            // 生成指定的Action类
            echo "输入Action名称[例如 User ]:";
            $action = trim(fgets(STDIN, 256));
            buildAction($action);
            begin();
            break;
        default:
            begin();
    }
}
Example #3
0
function insert_sql_data( $db_conn, $p_campaigns, $p_headers, $p_details )
// insert the header and detail data into the file
// with appropriate safeguards to ensure full 
// completion or rollback of the transaction.
{
GLOBAL $msg_log;

	$success = TRUE;
// Wrap all this in a transaction
// First, turn off autocommit
	$qry = "set autocommit=0";
//pre_echo( $qry );
	$success = mysql_query( $qry, $db_conn );

// Second, take care of all ALTER TABLE queries.  Due to a (documented)
// glitch in MySQL, these commands force a transaction to commit, 
// which sucks.

	if ($success) 
	{ // Create the temp_header table
		$qry = "CREATE TEMPORARY TABLE temp_header LIKE contract_header";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success) 
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

	if ($success) 
	{ // Create the temp_detail table
		$qry = "CREATE TEMPORARY TABLE temp_detail LIKE contract_detail";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

	if ($success) 
	{ // Delete the Seq field from table temp_header
		$qry = "ALTER TABLE temp_header DROP COLUMN Seq";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

    if ($success) 
	{ // Delete the Line column from table temp_detail
		$qry = "ALTER TABLE temp_detail DROP COLUMN Line";
//pre_echo( $qry );
		$success = mysql_query( $qry, $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

// loop through the campaigns, headers, and details to insert the
// data into the SQL database.  Keep solid track of all error
// results so that we can ROLLBACK on any error.
	if ($success) 
	{
//echo "<pre>";
//var_dump( $p_campaigns );  echo "</pre><br>";
		$success = begin( $db_conn );
		if (!$success)
		{
			message_log_append( $msg_log, "Error in START TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	}

// do the work here, and keep track of $success
// If we need to create a new agency record, do that here.
	$new_agency = FALSE;
	if ($success && is_null( $p_campaigns[0][ 'Agency Record' ])) 
	{
		$agent_name = $p_campaigns[0][ 'Agency Name' ];
		$rate = DEFAULT_AGENCY_RATE / 10;
		if ($success = agency_insert( $db_conn, $agent_name, $rate, $aindex )) 
		{
			$p_campaigns[0][ 'Agency Record' ] = agency_record( $agent_name, OPERATOR_NAME );
			$success = !is_null( $p_campaigns[0][ 'Agency Record' ]);
		} // if agency_insert
		if ($success) 
		{
			$new_agency = TRUE;
			message_log_append( $msg_log, "Agency created: " .
			"Seq = $aindex, Name = '$agent_name'", MSG_LOG_WARNING );
		} 
		else 
		{
			message_log_append( $msg_log, "Error while creating " . "Agency '$agent_name': " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	} // if null agency record

// If we need to create a new customer record, do that here.

	$new_customer = FALSE;
	if ($success && is_null( $p_campaigns[0][ 'Customer Record' ])) 
	{
		$cust_name = $p_campaigns[0][ 'Customer Name' ];
		$rate = DEFAULT_CUST_DISCOUNT;
		if ($success = customer_insert( $db_conn, $cust_name, $rate, $cindex )) 
		{
			$p_campaigns[0][ 'Customer Record' ] = cust_record( $cust_name, OPERATOR_NAME );
			$success = !is_null( $p_campaigns[0][ 'Customer Record' ]);
		} // if customer_insert
		if ($success) 
		{
			$new_customer = TRUE;
			message_log_append( $msg_log, "Customer created: " . "Seq = $cindex, Name = '$cust_name'", MSG_LOG_WARNING );
		} 
		else 
		{
			message_log_append( $msg_log, "Error while creating " . "Customer '$cust_name' " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	} // if null customer record

	if ($success) 
	{
// build the list of header fields, in order with 'quote required' flag
//  [n][0] is field name, [n][1] is boolean T=quote required, F=not
		$hdr_flds = build_header_field_array();
// A SQL INSERT statement lead-in
		$hdr_sql  = "INSERT INTO temp_header ( ";
		$hdr_sql .= fld_list( $hdr_flds ) . ") VALUES\n";

// build the list of detail fields, in order with 'quote required' flag
//  [n][0] is field name, [n][1] is boolean T=quote required, F=not

		$det_flds = build_detail_field_array();

// A SQL INSERT statement lead-in
		$det_sql  = "INSERT INTO temp_detail ( ";
		$det_sql .= fld_list( $det_flds ) . ") VALUES ";

// Here we go.  We'll loop through each contract header record,
// and its accompanying detail records.

		$n_inserted = 0;

		while ($success && (list( $key ) = each( $p_headers ))) 
		{
		    if (count( $p_details[ $key ] ) > 0) 
			{
//	If we created a new agency or customer above, update 
//	the respective header fields.
				if ($new_customer) 
				{
					$p_headers[ $key ][ 'CIndex' ] = $cindex;
					$p_headers[ $key ][ 'Discount' ] = $p_campaigns[0][ 'Customer Record' ][ 'Discount' ];
				}
				if ($new_agency) 
				{
					$p_headers[ $key ][ 'AIndex' ] = $aindex;
					$p_headers[ $key ][ 'AgencyComm' ] = $p_campaigns[0][ 'Agency Record' ][ 'Rate' ];
				}
				$row = data_values( $hdr_flds, $p_headers[ $key ] );
				$sql_header  = $hdr_sql;	// INSERT INTO ... VALUES
				$sql_header .= "(" . $row . ");";

				$rows = "";
				foreach ($p_details[ $key ] as $line)
				{
					$rows .= ",\n( " . data_values( $det_flds, $line ) . " )";
				}
				$rows = substr( $rows, 1 );	// remove comma-newline
				$sql_detail  = $det_sql;	// INSERT INTO ... VALUES
				$sql_detail .= $rows;

				if ($success = do_insert( $db_conn, $sql_header, $sql_detail ))
				{
					$n_inserted++;
				}
			} // if detail count > 0
		} // while success and each key
	} // if success

	if ($success) 
	{
		$success = commit( $db_conn );
		if ($success)
		{
			message_log_append( $msg_log, "$n_inserted contract" . ($n_inserted == 1 ? '' : 's') . " imported" );
		}
		else 
		{
			message_log_append( $msg_log, "Error in COMMIT TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
			if (!rollback( $db_conn ))
			{
				message_log_append( $msg_log, "Error in ROLLBACK TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
			}
		}
	} 
	else 
	{
		if (!rollback( $db_conn ))
		{
			message_log_append( $msg_log, "Error in ROLLBACK TRANSACTION: " . mysql_error( $db_conn ), MSG_LOG_ERROR );
		}
	} // if success
	return( $success );
} // insert_sql_data
Example #4
0
 function save($oData)
 {
     if (!$oData["id_orden_compra"]) {
         begin();
         $detalle = array();
         $cabecera = array();
         $cabecera = explode("@@", $oData["cabecera"]);
         $detalle = explode("||", $oData["detalle"]);
         $sql = "INSERT INTO  ordenes_compra (id_proveedor, fecha_orden_compra, nro_orden_compra, generada)\r\n\t\t\t\t\tVALUES (" . $cabecera[0] . ", '" . dateToMySQL($cabecera[1]) . "', " . $cabecera[2] . ", 1)";
         if (!mysql_query($sql)) {
             die('Error: ' . mysql_error());
             rollback();
             return false;
         } else {
             $id = mysql_insert_id();
             foreach ($detalle as $detail) {
                 $values = explode("@@", $detail);
                 $sql = "INSERT INTO detalle_ordenes_compra (id_orden_compra, id_producto, cantidad_detalle_orden_compra) VALUES  (" . $id . ", " . $values[0] . ", " . $values[1] . ")";
                 if (!mysql_query($sql)) {
                     die('Error: ' . mysql_error());
                     rollback();
                     break;
                 }
             }
             if ($cabecera[2]) {
                 $nroVta = $cabecera[2] + 1;
             }
             $sql = "UPDATE parametros SET valor_parametro = " . $nroVta . " WHERE nombre_parametro='nro_orden_compra'";
             if (!mysql_query($sql)) {
                 die('Error: ' . mysql_error());
                 rollback();
                 break;
             } else {
                 commit();
                 return true;
             }
             return false;
         }
     } else {
         $sql = "delete from detalle_ordenes_compra where id_orden_compra=" . $oData["id_orden_compra"];
         getRS($sql);
         $sql = "delete from ordenes_compra where id_orden_compra=" . $oData["id_orden_compra"];
         getRS($sql);
         begin();
         $detalle = array();
         $cabecera = array();
         $cabecera = explode("@@", $oData["cabecera"]);
         $detalle = explode("||", $oData["detalle"]);
         $sql = "INSERT INTO  ordenes_compra (id_proveedor, fecha_orden_compra, nro_orden_compra, generada)\r\n\t\t\t\t\tVALUES (" . $cabecera[0] . ", '" . dateToMySQL($cabecera[1]) . "', " . $cabecera[2] . ", 1)";
         if (!mysql_query($sql)) {
             die('Error: ' . mysql_error());
             rollback();
             return false;
         } else {
             $id = mysql_insert_id();
             foreach ($detalle as $detail) {
                 $values = explode("@@", $detail);
                 $sql = "INSERT INTO detalle_ordenes_compra (id_orden_compra, id_producto, cantidad_detalle_orden_compra) VALUES  (" . $id . ", " . $values[0] . ", " . $values[1] . ")";
                 if (!mysql_query($sql)) {
                     die('Error: ' . mysql_error());
                     rollback();
                     break;
                 }
             }
             if ($cabecera[2]) {
                 $nroVta = $cabecera[2] + 1;
             }
             $sql = "UPDATE parametros SET valor_parametro = " . $nroVta . " WHERE nombre_parametro='nro_orden_compra'";
             if (!mysql_query($sql)) {
                 die('Error: ' . mysql_error());
                 rollback();
                 break;
             } else {
                 commit();
                 return true;
             }
             return false;
         }
     }
 }
Example #5
0
function begin($startX, $startY)
{
    if ($startY > 0 && $startY == $startX) {
        begin($startY - 1, $startY - 1, $board);
    }
    if ($startX > 0) {
        begin($startX - 1, $startY, $board);
    }
    $board = newBoard();
    $board[$startY][$startX] = 1;
    //the first move location will be "1"
    echo "Starting at: (" . $startY . "," . $startX . ")\n";
    $solution = solve($board, $startY, $startX, 2);
}
Example #6
0
function do_install()
{
    // {{{
    if (isset($_POST['database_type']) && isset($_POST['database_host']) && isset($_POST['database_user']) && isset($_POST['database_name'])) {
        global $database_dsn;
        $database_dsn = "{$_POST['database_type']}:user={$_POST['database_user']};password={$_POST['database_password']};host={$_POST['database_host']};dbname={$_POST['database_name']}";
        install_process();
    } else {
        if (file_exists("auto_install.conf")) {
            install_process(trim(file_get_contents("auto_install.conf")));
            unlink("auto_install.conf");
        } else {
            begin();
        }
    }
}
Example #7
0
 public function rewind()
 {
     begin($this->_config);
 }
Example #8
0
 function lexer_performAction(&$yy, $yy_, $avoiding_name_collisions, $YY_START = null)
 {
     $YYSTATE = $YY_START;
     switch ($avoiding_name_collisions) {
         case 0:
             return 15;
             break;
         case 1:
             return 15;
             break;
         case 2:
             this . popState();
             this . begin('STRING');
             return 11;
             break;
         case 3:
             this . popState();
             return 15;
             break;
         case 4:
             this . begin('SINGLE_QUOTE_ON');
             return 'SINGLE_QUOTE_ON';
             break;
         case 5:
             this . begin('SINGLE_QUOTE_ON');
             return 10;
             break;
         case 6:
             return 15;
             break;
         case 7:
             return 15;
             break;
         case 8:
             this . popState();
             this . begin('STRING');
             return 11;
             break;
         case 9:
             this . popState();
             return 15;
             break;
         case 10:
             this . begin('DOUBLE_QUOTE_ON');
             return 10;
             break;
         case 11:
             this . begin('DOUBLE_QUOTE_ON');
             return 10;
             break;
         case 12:
             return 14;
             break;
         case 13:
             this . popState();
             return 7;
             break;
         case 14:
             this . popState();
             return 13;
             break;
         case 15:
             return 12;
             break;
         case 16:
             return 15;
             break;
         case 17:
             return 15;
             break;
         case 18:
             return 15;
             break;
         case 19:
             return 15;
             break;
         case 20:
             return 8;
             break;
         case 21:
             this . begin('STRING');
             return 15;
             break;
         case 22:
             return 5;
             break;
     }
 }
<?php

/* 
 * The MIT License
 *
 * Copyright 2015 ekow.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
begin()->table('some_table')->column('id')->type('integer')->nulls(false)->column('some_field')->type('string')->column('another_field')->type('string')->primaryKey('id')->autoIncrement()->end();
Example #10
0
 function saveIndiceEstacional($oData)
 {
     begin();
     $sql = "SELECT * FROM indices_estacionales WHERE id_producto = " . $oData["id_producto"];
     $result = getRS($sql);
     if (!getNrosRows($result)) {
         $dur_periodo = $this->getDuracionPeriodo();
         $cant_dias_anio = date("z", mktime(0, 0, 0, 12, 31, date("Y"))) + 1;
         $periodo_x_anio = number_format($cant_dias_anio / $dur_periodo);
         for ($i = 0; $i < $periodo_x_anio; $i++) {
             if ($i + 1 == $oData["nro_estacion"]) {
                 $sql = "INSERT INTO indices_estacionales (id_producto, orden, valor) VALUES (" . $oData["id_producto"] . "," . ($i + 1) . ", " . $oData["indice_estacional"] . ")";
             } else {
                 $sql = "INSERT INTO indices_estacionales (id_producto, orden) VALUES (" . $oData["id_producto"] . "," . ($i + 1) . ")";
             }
             $rs = getRS($sql);
             if (!$rs) {
                 die('Error: ' . mysql_error());
                 rollback();
             } else {
                 commit();
             }
         }
     } else {
         $sql = "SELECT * FROM indices_estacionales WHERE id_producto = " . $oData["id_producto"] . " and orden = " . $oData["nro_estacion"];
         $result = getRS($sql);
         if (!getNrosRows($result)) {
             $sql = "INSERT INTO indices_estacionales (id_producto, orden, valor) VALUES (" . $oData["id_producto"] . "," . $oData["nro_estacion"] . ", " . $oData["indice_estacional"] . ")";
             $rs = getRS($sql);
             if (!$rs) {
                 die('Error: ' . mysql_error());
                 rollback();
             }
         } else {
             $sql = "UPDATE indices_estacionales SET valor = " . $oData["indice_estacional"] . " WHERE id_producto = " . $oData["id_producto"] . " AND orden = " . $oData["nro_estacion"];
             $rs = getRS($sql);
             if (!$rs) {
                 die('Error: ' . mysql_error());
                 rollback();
             }
         }
     }
 }
Example #11
0
<?php

/* 
 * The MIT License
 *
 * Copyright 2014 ekow.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
begin()->table('users')->column('branch_id')->type('integer')->nulls(true)->column('picture_id')->type('integer')->nulls(true)->column('department_id')->type('integer')->nulls(true)->column('phone')->type('string')->nulls(true)->column('email')->type('string')->nulls(false)->column('user_status')->type('double')->nulls(true)->column('other_names')->type('string')->nulls(true)->column('last_name')->type('string')->nulls(false)->column('first_name')->type('string')->nulls(false)->column('role_id')->type('integer')->nulls(true)->column('password')->type('string')->nulls(false)->column('user_name')->type('string')->nulls(false)->column('user_id')->type('integer')->nulls(false)->primaryKey('user_id')->name('user_id_pk')->autoIncrement()->unique('user_name')->name('user_name_uk')->table('roles')->column('role_name')->type('string')->nulls(true)->column('role_id')->type('integer')->nulls(false)->primaryKey('role_id')->name('role_id_pk')->autoIncrement()->table('departments')->column('department_name')->type('string')->nulls(false)->column('department_id')->type('integer')->nulls(false)->primaryKey('department_id')->name('department_id_pk')->autoIncrement()->table('temporary_roles')->column('tag')->type('string')->nulls(true)->column('original_role_id')->type('integer')->nulls(true)->column('active')->type('boolean')->nulls(true)->column('expires')->type('timestamp')->nulls(true)->column('created')->type('timestamp')->nulls(true)->column('user_id')->type('integer')->nulls(true)->column('new_role_id')->type('integer')->nulls(true)->column('temporary_role_id')->type('integer')->nulls(false)->primaryKey('temporary_role_id')->name('temporary_role_id_pk')->autoIncrement()->table('suppliers')->column('user_id')->type('integer')->nulls(true)->column('telephone')->type('string')->nulls(true)->column('address')->type('string')->nulls(true)->column('supplier_name')->type('string')->nulls(false)->column('supplier_id')->type('integer')->nulls(false)->primaryKey('supplier_id')->name('supplier_id_pk')->autoIncrement()->table('countries')->column('currency_symbol')->type('string')->nulls(true)->column('currency')->type('string')->nulls(true)->column('nationality')->type('string')->nulls(true)->column('country_code')->type('string')->nulls(true)->column('country_name')->type('string')->nulls(false)->column('country_id')->type('integer')->nulls(false)->primaryKey('country_id')->name('country_id_pk')->autoIncrement()->unique('country_name')->name('country_name_uk')->table('permissions')->column('module')->type('string')->nulls(true)->column('value')->type('double')->nulls(false)->column('permission')->type('string')->nulls(true)->column('role_id')->type('integer')->nulls(false)->column('permission_id')->type('integer')->nulls(false)->primaryKey('permission_id')->name('perm_id_pk')->autoIncrement()->table('notes')->column('user_id')->type('integer')->nulls(false)->column('item_type')->type('string')->nulls(false)->column('item_id')->type('integer')->nulls(false)->column('note_time')->type('timestamp')->nulls(false)->column('note')->type('string')->nulls(true)->column('note_id')->type('integer')->nulls(false)->primaryKey('note_id')->name('notes_note_id_pk')->autoIncrement()->table('regions')->column('country_id')->type('integer')->nulls(false)->column('name')->type('string')->nulls(false)->column('region_code')->type('string')->nulls(false)->column('region_id')->type('integer')->nulls(false)->primaryKey('region_id')->name('region_id_pk')->autoIncrement()->unique('name')->name('region_name_uk')->table('note_attachments')->column('object_id')->type('integer')->nulls(true)->column('note_id')->type('integer')->nulls(true)->column('description')->type('string')->nulls(true)->column('note_attachment_id')->type('integer')->nulls(false)->primaryKey('note_attachment_id')->name('note_attachments_pkey')->autoIncrement()->table('branches')->column('city_id')->type('integer')->nulls(true)->column('address')->type('text')->nulls(true)->column('branch_name')->type('string')->nulls(false)->column('branch_id')->type('integer')->nulls(false)->primaryKey('branch_id')->name('branches_pkey')->autoIncrement()->table('clients')->column('branch_id')->type('integer')->nulls(false)->column('marital_status')->type('double')->nulls(true)->column('gender')->type('double')->nulls(true)->column('nationality_id')->type('integer')->nulls(true)->column('company_name')->type('string')->nulls(true)->column('contact_person')->type('string')->nulls(true)->column('in_trust_for')->type('string')->nulls(true)->column('country_id')->type('integer')->nulls(true)->column('id_issue_date')->type('date')->nulls(true)->column('id_issue_place')->type('string')->nulls(true)->column('signature')->type('string')->nulls(true)->column('scanned_id')->type('string')->nulls(true)->column('picture')->type('string')->nulls(true)->column('occupation')->type('string')->nulls(true)->column('residential_status')->type('double')->nulls(true)->column('id_number')->type('string')->nulls(false)->column('id_type_id')->type('integer')->nulls(false)->column('city_id')->type('integer')->nulls(true)->column('birth_date')->type('date')->nulls(true)->column('email')->type('string')->nulls(true)->column('fax')->type('string')->nulls(true)->column('mobile')->type('string')->nulls(true)->column('contact_tel')->type('string')->nulls(true)->column('residential_address')->type('string')->nulls(true)->column('mailing_address')->type('string')->nulls(false)->column('previous_names')->type('string')->nulls(true)->column('other_names')->type('string')->nulls(true)->column('first_name')->type('string')->nulls(true)->column('surname')->type('string')->nulls(true)->column('title')->type('string')->nulls(true)->column('account_type')->type('double')->nulls(false)->column('main_client_id')->type('integer')->nulls(false)->primaryKey('main_client_id')->name('clients_main_client_id_pk')->autoIncrement()->table('identification_types')->column('id_name')->type('string')->nulls(false)->column('id_type_id')->type('integer')->nulls(false)->primaryKey('id_type_id')->name('id_type_id_pk')->autoIncrement()->table('client_users')->column('status')->type('integer')->nulls(false)->column('user_name')->type('string')->nulls(false)->column('password')->type('string')->nulls(false)->column('membership_id')->type('integer')->nulls(true)->column('main_client_id')->type('integer')->nulls(true)->column('client_user_id')->type('integer')->nulls(false)->primaryKey('client_user_id')->name('client_users_client_user_id_pk')->autoIncrement()->table('client_joint_accounts')->column('mobile')->type('string')->nulls(true)->column('id_issue_date')->type('date')->nulls(true)->column('id_issue_place')->type('string')->nulls(true)->column('id_number')->type('string')->nulls(true)->column('id_type_id')->type('integer')->nulls(true)->column('office_telephone')->type('string')->nulls(true)->column('telephone')->type('string')->nulls(true)->column('address')->type('string')->nulls(true)->column('previous_names')->type('string')->nulls(true)->column('other_names')->type('string')->nulls(true)->column('first_name')->type('string')->nulls(false)->column('surname')->type('string')->nulls(false)->column('title')->type('string')->nulls(true)->column('main_client_id')->type('integer')->nulls(false)->column('joint_account_id')->type('integer')->nulls(false)->primaryKey('joint_account_id')->name('joint_account_id_pk')->autoIncrement()->table('cities')->column('region_id')->type('integer')->nulls(false)->column('city_name')->type('string')->nulls(false)->column('city_id')->type('integer')->nulls(false)->primaryKey('city_id')->name('city_id_pk')->autoIncrement()->unique('city_name')->name('city_name_uk')->table('bank_branches')->column('sort_code')->type('string')->nulls(false)->defaultValue("0")->column('address')->type('string')->nulls(true)->column('branch_name')->type('string')->nulls(false)->column('bank_id')->type('integer')->nulls(false)->column('bank_branch_id')->type('integer')->nulls(false)->primaryKey('bank_branch_id')->name('bank_branch_id_pk')->autoIncrement()->table('banks')->column('swift_code')->type('string')->nulls(true)->defaultValue("0")->column('bank_code')->type('string')->nulls(false)->defaultValue("0")->column('bank_name')->type('string')->nulls(false)->column('bank_id')->type('integer')->nulls(false)->primaryKey('bank_id')->name('bank_id_pk')->autoIncrement()->unique('bank_name')->name('bank_name_uk')->table('api_keys')->column('secret')->type('string')->nulls(false)->column('key')->type('string')->nulls(false)->column('active')->type('boolean')->nulls(false)->column('user_id')->type('integer')->nulls(false)->column('api_key_id')->type('integer')->nulls(false)->primaryKey('api_key_id')->name('api_keys_pkey')->autoIncrement()->table('relationships')->column('relationship_name')->type('string')->nulls(false)->column('relationship_id')->type('integer')->nulls(false)->primaryKey('relationship_id')->name('relationship_id_pk')->autoIncrement()->table('notifications')->column('subject')->type('string')->nulls(true)->column('email')->type('text')->nulls(true)->column('sms')->type('text')->nulls(true)->column('tag')->type('string')->nulls(true)->column('notification_id')->type('integer')->nulls(false)->primaryKey('notification_id')->name('notifications_pkey')->autoIncrement()->table('holidays')->column('holiday_date')->type('date')->nulls(false)->column('name')->type('string')->nulls(false)->column('holiday_id')->type('integer')->nulls(false)->primaryKey('holiday_id')->name('holidays_holiday_id_pk')->autoIncrement()->table('configurations')->column('value')->type('string')->nulls(true)->column('key')->type('string')->nulls(true)->column('configuration_id')->type('integer')->nulls(false)->primaryKey('configuration_id')->name('configuration_id_pk')->autoIncrement()->unique('key')->name('key_uk')->table('cheque_formats')->column('data')->type('text')->nulls(false)->column('description')->type('string')->nulls(false)->column('cheque_format_id')->type('integer')->nulls(false)->primaryKey('cheque_format_id')->name('cheque_formats_cheque_format_id_pk')->autoIncrement()->table('binary_objects')->column('data')->type('blob')->nulls(true)->column('object_id')->type('integer')->nulls(false)->primaryKey('object_id')->name('binary_objects_pkey')->autoIncrement()->table('audit_trail_data')->column('data')->type('text')->nulls(true)->column('audit_trail_id')->type('integer')->nulls(false)->column('audit_trail_data_id')->type('integer')->nulls(false)->primaryKey('audit_trail_data_id')->name('audit_trail_data_id_pk')->autoIncrement()->index('audit_trail_id')->name('audit_trail_id_idx')->table('audit_trail')->column('data')->type('text')->nulls(true)->column('type')->type('double')->nulls(false)->column('audit_date')->type('timestamp')->nulls(false)->column('description')->type('string')->nulls(false)->column('item_type')->type('string')->nulls(false)->column('item_id')->type('integer')->nulls(false)->column('user_id')->type('integer')->nulls(false)->column('audit_trail_id')->type('integer')->nulls(false)->primaryKey('audit_trail_id')->name('audit_trail_audit_id_pk')->autoIncrement()->index('item_id')->name('audit_trail_item_id_idx')->table('locations')->column('address')->type('string')->nulls(true)->column('name')->type('string')->nulls(true)->column('location_id')->type('integer')->nulls(false)->primaryKey('location_id')->name('location_id_pk')->autoIncrement()->view('users_view')->definition("SELECT * FROM users JOIN roles USING (role_id)")->view('countries_view')->definition("SELECT * FROM countries JOIN regions USING (country_id)")->table('users')->foreignKey('branch_id')->references(reftable('branches'))->columns('branch_id')->table('users')->foreignKey('department_id')->references(reftable('departments'))->columns('department_id')->table('users')->foreignKey('role_id')->references(reftable('roles'))->columns('role_id')->name('users_role_id_fk')->table('temporary_roles')->foreignKey('new_role_id')->references(reftable('roles'))->columns('role_id')->name('temporary_rol_new_role_id_fk')->table('temporary_roles')->foreignKey('original_role_id')->references(reftable('roles'))->columns('role_id')->name('temporary_rol_orig_role_id_fk')->table('temporary_roles')->foreignKey('user_id')->references(reftable('users'))->columns('user_id')->name('temporary_roles_user_id_fk')->table('suppliers')->foreignKey('user_id')->references(reftable('users'))->columns('user_id')->name('suppliers_user_id_fk')->table('permissions')->foreignKey('role_id')->references(reftable('roles'))->columns('role_id')->name('permissios_role_id_fk')->table('notes')->foreignKey('user_id')->references(reftable('users'))->columns('user_id')->name('notes_user_id_fk')->table('regions')->foreignKey('country_id')->references(reftable('countries'))->columns('country_id')->name('regions_country_id_fk')->table('note_attachments')->foreignKey('note_id')->references(reftable('notes'))->columns('note_id')->name('note_attachments_note_id_fkey')->table('clients')->foreignKey('branch_id')->references(reftable('branches'))->columns('branch_id')->name('clients_branch_id_fkey')->table('clients')->foreignKey('city_id')->references(reftable('cities'))->columns('city_id')->name('clients_city_id_fk')->table('clients')->foreignKey('country_id')->references(reftable('countries'))->columns('country_id')->name('clients_country_id_fk')->table('clients')->foreignKey('id_type_id')->references(reftable('identification_types'))->columns('id_type_id')->name('clients_id_type_id_fk')->table('clients')->foreignKey('nationality_id')->references(reftable('countries'))->columns('country_id')->name('clients_nationality_id_fk')->table('client_users')->foreignKey('main_client_id')->references(reftable('clients'))->columns('main_client_id')->name('client_users_main_client_id_fk')->table('client_joint_accounts')->foreignKey('id_type_id')->references(reftable('identification_types'))->columns('id_type_id')->name('client_joint_id_type_id_fk')->table('client_joint_accounts')->foreignKey('main_client_id')->references(reftable('clients'))->columns('main_client_id')->name('client_joint_main_client_id_fk')->table('cities')->foreignKey('region_id')->references(reftable('regions'))->columns('region_id')->name('cities_region_id_fk')->table('bank_branches')->foreignKey('bank_id')->references(reftable('banks'))->columns('bank_id')->name('branch_bank_id_fk')->table('api_keys')->foreignKey('user_id')->references(reftable('users'))->columns('user_id')->name('api_keys_user_id_fkey')->end();
function file_begin($filename)
{
    return begin(explode(".", $filename));
}
Example #13
0
	//Verificando que la conexion se haya hecho a la BD
	if (!$conexion_base) {
		die ('No se encuentra la base de datos seleccionada : ' . mysql_error());
	}
	
	$lNumber = $_POST['leaseNum'];
	$sDate = $_POST['sDate'];
	$eDate = $_POST['eDate'];
	$duration = $_POST['duration'];
	$studentID = $_POST['student'];
	$placeNum = $_POST['room'];
	

	$contrato = "INSERT INTO Lease VALUES ('$lNumber', '$sDate', '$eDate', '$duration', '$studentID', '$placeNum')";
	begin(); // Empieza la transaccion
	$result = mysql_query($contrato);
	
	if(!$result) {
		
		rollback(); // Si hubo un error se le da rollback
		echo 'Hubo un error';
		exit;
	}
	
	else {
		commit(); //Si fue exitosa se lleva a cabo
		echo 'Operación realizada con éxito';
	}
	
	
Example #14
0
function do_install()
{
    // {{{
    if (isset($_POST['database_dsn'])) {
        install_process($_POST['database_dsn']);
    } else {
        if (file_exists("auto_install.conf")) {
            install_process(trim(file_get_contents("auto_install.conf")));
            unlink("auto_install.conf");
        } else {
            begin();
        }
    }
}
Example #15
0
<?php

/* 
 * The MIT License
 *
 * Copyright 2014 ekow.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
begin()->table('roles')->column('role_name')->type('string')->nulls(false)->table('users')->column('user_name')->rename('username')->end();
Example #16
0
<html>
  <body>
    <?php 
$scriptName = "ViewUserInfo.php";
include "PHPprinter.php";
$startTime = getMicroTime();
$userId = $HTTP_POST_VARS['userId'];
if ($userId == null) {
    $userId = $HTTP_GET_VARS['userId'];
    if ($userId == null) {
        printError($scriptName, $startTime, "Viewing user information", "You must provide an item identifier!<br>");
        exit;
    }
}
getDatabaseLink($link);
begin($link);
$userResult = mysql_query("SELECT * FROM users WHERE users.id={$userId}", $link) or die("ERROR: Query failed");
if (mysql_num_rows($userResult) == 0) {
    commit($link);
    die("<h3>ERROR: Sorry, but this user does not exist.</h3><br>\n");
}
printHTMLheader("RUBiS: View user information");
// Get general information about the user
$userRow = mysql_fetch_array($userResult);
$firstname = $userRow["firstname"];
$lastname = $userRow["lastname"];
$nickname = $userRow["nickname"];
$email = $userRow["email"];
$creationDate = $userRow["creation_date"];
$rating = $userRow["rating"];
print "<h2>Information about " . $nickname . "<br></h2>";
<?php

/* 
 * The MIT License
 *
 * Copyright 2015 ekow.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
begin()->table('some_table')->rename('some_other_table')->end();
Example #18
0
             // can change row on a different page without unique key
             if (!$result) {
                 break;
             }
             $affected += $connection->affected_rows;
         }
         queries_redirect(remove_from_uri(), lang('%d item(s) have been affected.', $affected), $result);
     }
 } elseif (is_string($file = get_file("csv_file", true))) {
     //! character set
     cookie("adminer_import", "output=" . urlencode($adminer_import["output"]) . "&format=" . urlencode($_POST["separator"]));
     $result = true;
     $cols = array_keys($fields);
     preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~', $file, $matches);
     $affected = count($matches[0]);
     begin();
     $separator = $_POST["separator"] == "csv" ? "," : ($_POST["separator"] == "tsv" ? "\t" : ";");
     foreach ($matches[0] as $key => $val) {
         preg_match_all("~((\"[^\"]*\")+|[^{$separator}]*){$separator}~", $val . $separator, $matches2);
         if (!$key && !array_diff($matches2[1], $cols)) {
             //! doesn't work with column names containing ",\n
             // first row corresponds to column names - use it for table structure
             $cols = $matches2[1];
             $affected--;
         } else {
             $set = array();
             foreach ($matches2[1] as $i => $col) {
                 $set[idf_escape($cols[$i])] = $col == "" && $fields[$cols[$i]]["null"] ? "NULL" : q(str_replace('""', '"', preg_replace('~^"|"$~', '', $col)));
             }
             $result = insert_update($TABLE, $set, $primary);
             if (!$result) {
 function executePolitica_SR()
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM productos p\r\n\t\t\t\t  INNER JOIN agotamientos_permitidos ap\r\n\t\t\t\t\tON ap.id_agotamiento = p.id_agotamiento\r\n\t\t\t\tWHERE id_politica = 2";
     $rs = getRS($sql);
     if (getNrosRows($rs)) {
         $flag = false;
         while ($row = getRow($rs)) {
             $sql = "SELECT *\r\n\t\t\t\t\t\tFROM ordenes_compra oc\r\n\t\t\t\t\t\t  INNER JOIN detalle_ordenes_compra doc\r\n\t\t\t\t\t\t\tON doc.id_orden_compra = oc.id_orden_compra\r\n\t\t\t\t\t\t\t  AND id_producto = " . $row["id_producto"] . "\r\n\t\t\t\t\t\tORDER BY fecha_orden_compra DESC LIMIT 1";
             $rsOC = getRS($sql);
             $rowOC = getRow($rsOC);
             $fechaOC = $rowOC["fecha_orden_compra"];
             $fechaActual = date("Y-m-d");
             $diferencia = getDiferenciaEntreFechas($fechaOC, $fechaActual);
             $R = $row["tpo_de_reaprovisionamiento_producto"];
             if ($diferencia >= $R) {
                 $R = $R / 7;
                 // lo convierto a semanas
                 $A = $row["costo_de_emision_producto"];
                 $oData = array();
                 $oData["id_producto"] = $row["id_producto"];
                 $D = $this->getDemandaAnual($oData);
                 $H = $row["tasa_de_almacenamiento_producto"] * $row["precio_unitario_producto"];
                 $Q = number_format(sqrt(2 * $A * $D / $H));
                 $agotamiento = $row["agotamientos_perm_x_anio"];
                 $N = number_format($D / $Q);
                 $nivel_de_serv = 1 - $agotamiento / $N;
                 $k = $this->getFactorDeSeguridad($nivel_de_serv);
                 $data = $this->getMinTpoDeEntregaAndProv($oData);
                 $te = $data["tpo_de_entrega"];
                 $te_sobre_durEnSem = $te / $this->getDuracionPeriodoEnSemanas();
                 $days = number_format($te * 7 + $R);
                 $desv_std = $this->getDesvStd($oData, $days) * $te_sobre_durEnSem;
                 $SS = $k * $desv_std;
                 $mu_e = $this->getDemanda($oData, $days) * $te_sobre_durEnSem;
                 $S = number_format($mu_e + $SS);
                 if ($row["stock_actual_producto"] < $S) {
                     begin();
                     $sql = "UPDATE productos SET nivel_s_producto={$S}, stock_seguridad_producto={$SS} WHERE id_producto=" . $oData["id_producto"];
                     if (!getRS($sql)) {
                         rollback();
                         return false;
                     } else {
                         $exp = new ExpertoOrdenes();
                         $nro_orden = $exp->getNroOrdenCompra();
                         $sql = "INSERT INTO  ordenes_compra (fecha_orden_compra, nro_orden_compra, generada, id_proveedor)\r\n\t\t\t\t\t\t\t\t\tVALUES ('" . date("Y-m-d") . "', " . $nro_orden . ", 0, " . $data["id_proveedor"] . ")";
                         if (!getRS($sql)) {
                             rollback();
                             return false;
                         } else {
                             $id = mysql_insert_id();
                             $cant = $S - $row["stock_actual_producto"];
                             $sql = "INSERT INTO detalle_ordenes_compra (id_orden_compra, id_producto, cantidad_detalle_orden_compra) VALUES  (" . $id . ", " . $oData["id_producto"] . ", " . $cant . ")";
                             if (!getRS($sql)) {
                                 rollback();
                                 return false;
                             } else {
                                 $nro_orden += 1;
                                 $sql = "UPDATE parametros SET valor_parametro = " . $nro_orden . " WHERE nombre_parametro='nro_orden_compra'";
                                 if (!mysql_query($sql)) {
                                     die('Error: ' . mysql_error());
                                     rollback();
                                     return false;
                                 } else {
                                     commit();
                                     $flag = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return $flag;
     }
     return false;
 }