Example #1
0
	public function checkPermission ($id_user, $acl = 'PR', $operation = '', $id_workunit = -1) {
		$system = System::getInstance();
		
		$permission = false;
		if (dame_admin($id_user)) {
			$permission = true;
		} else {
			// Section access
			if ($system->checkACL($acl)) {
				// If the workunit exists, should belong to the user
				if ($operation == "delete_workunit") {
					if ($id_workunit > 0) {
						$user_workunit = get_db_value("id_user", "tworkunit", "id", $id_workunit);
						if (strcasecmp($id_user, $user_workunit) == 0) {
							$permission = true;
						}
					}
				} else {
					$permission = true;
				}
			}
		}
		
		return $permission;
	}
function process_values(&$values, $id_inventory)
{
    /* Check empty values */
    $values['id_manufacturer'] = $values['id_manufacturer'] ? $values['id_manufacturer'] : NULL;
    $values['id_building'] = $values['id_building'] ? $values['id_building'] : NULL;
    $values['id_sla'] = $values['id_sla'] ? $values['id_sla'] : NULL;
    $values['id_product'] = $values['id_product'] ? $values['id_product'] : NULL;
    $values['id_contract'] = $values['id_contract'] ? $values['id_contract'] : NULL;
    foreach ($values as $field => $value) {
        if ($id_inventory) {
            $values[$field] = isset($values[$field][0]) && $values[$field][0] == '`' ? get_db_value($values[$field], 'tinventory', 'id', $id_inventory) : $values[$field];
        } else {
            $values[$field] = isset($values[$field][0]) && $values[$field][0] == '`' ? '' : $values[$field];
        }
    }
}
Example #3
0
 public function checkPermission($id_user, $acl = 'IR', $operation = '', $id_incident = -1)
 {
     $system = System::getInstance();
     $permission = false;
     if (dame_admin($id_user)) {
         $permission = true;
     } else {
         if ($system->checkACL($this->acl)) {
             if ($id_incident > 0 && $operation == "delete") {
                 $incident_creator = get_db_value("id_creator", "tincidencia", "id_incidencia", $id_incident);
                 if ($system->checkACL("IM") && strcasecmp($id_user, $incident_creator) == 0) {
                     $permission = true;
                 }
             } else {
                 $permission = true;
             }
         }
     }
     return $permission;
 }
    require "general/noaccess.php";
    exit;
}
$id_nota = get_parameter("id", 0);
$id_incident = get_parameter("id_inc", 0);
// ********************************************************************
// Note detail of $id_note
// ********************************************************************
$sql4 = 'SELECT * FROM tnota WHERE id_nota = ' . $id_nota;
$res4 = mysql_query($sql4);
if ($row3 = mysql_fetch_array($res4)) {
    echo "<div class='notetitle'>";
    // titulo
    $timestamp = $row3["timestamp"];
    $nota = $row3["nota"];
    $id_usuario_nota = $row3["id_usuario"];
    $avatar = get_db_value("avatar", "tusuario", "id_usuario", $id_usuario_nota);
    // Show data
    echo "<img src='images/avatars/" . $avatar . ".png' class='avatar_small'>&nbsp;";
    echo " <a href='index.php?sec=users&sec2=operation/users/user_edit&id={$id_usuario_nota}'>";
    echo $id_usuario_nota;
    echo "</a>";
    echo " " . __("said on {$timestamp}");
    echo "</div>";
    // Body
    echo "<div class='notebody'>";
    echo clean_output_breaks($nota);
    echo "</div>";
} else {
    echo __('No data available');
}
				//$tracking_group = "<table class='details_table alternate'>";
				foreach ($stats[INCIDENT_METRIC_GROUP] as $key => $value) {
					$name = get_db_value ('nombre', 'tgrupo', 'id_grupo', $key);
					$tracking_group = "<tr>";
					$tracking_group .= "<td><strong>".$name."</strong>:</td>";
					$tracking_group .= "<td style='text-align:right;'>".give_human_time($value,true,true,true)."</td>";
					$tracking_group .= "</tr>";
				}
				//$tracking_group .= "</table>";
				
				echo print_container('incident_tracking_group', __('Statistics by group'), $tracking_group, 'open', true, '20px', '', '', 1, 'less_widht');
			echo "</td>";	
			echo "<td style='vertical-align:top;width: 33%;'>";
				//$tracking_user = "******";
				foreach ($stats[INCIDENT_METRIC_USER] as $key => $value) {
					$name = get_db_value ('nombre_real', 'tusuario', 'id_usuario', $key);
					$tracking_user = "******";
					$tracking_user .= "<td><strong>".$name."</strong>:</td>";
					$tracking_user .= "<td style='text-align:right;'>".give_human_time($value,true,true,true)."</td>";
					$tracking_user .= "</tr>";
				}
				//$tracking_user .= "</table>";
				
				echo print_container('incident_tracking_user', __('Statistics by owner'), $tracking_user, 'open', true, '20px', '', '', 1, 'less_widht');
			echo "</td>";	
		echo "</tr>";
	echo "</table>";
}

$trackings = get_db_all_rows_field_filter ('tincident_track', 'id_incident', $id, 'timestamp DESC, id_it DESC');
function DMR_DM_PRESTAMO_show()
{
    global $db;
    global $sAction;
    global $sForm;
    global $sFileName;
    global $sPRESTAMOErr;
    global $styles;
    global $login_err;
    $fldPRES_ID = "";
    $fldRADI_NUME_RADI = "";
    $fldUSUA_LOGIN_ACTU = "";
    $fldDEPE_CODI = "";
    $fldPRES_FECH_PEDI = "";
    $fldPRES_REQUERIMIENTO = "";
    $fldUSUA_LOGIN_PRES = "";
    $fldPRES_FECH_PRES = "";
    $fldPRES_DESC = "";
    $fldPRES_ESTADO = "";
    //-------------------------------
    // PRESTAMO Show begin
    //-------------------------------
    $sFormTitle = "DevoluciĆ³n Masiva";
    $sWhere = "";
    $bPK = true;
    $fldPRES_FECH_DEVO = Date('d/m/Y h:i');
    ?>
   
   <table class="FormTABLE">
   <form method="POST" action="<?php 
    echo $sFileName;
    ?>
" name="PRESTAMO">
   <tr><td class="FormHeaderTD" colspan="2"><font class="FormHeaderFONT"><?php 
    echo $sFormTitle;
    ?>
</font></td></tr>
   <?php 
    if ($sPRESTAMOErr) {
        ?>
		<tr><td class="DataTD" colspan="2"><font class="ErrorFONT"><?php 
        echo $sPRESTAMOErr;
        ?>
</font></td></tr>
	 <?php 
    }
    ?>
    <?php 
    if (strlen($login_err)) {
        ?>
    <tr><td colspan="2"><font Class="ErrorFONT"><?php 
        echo $login_err;
        ?>
</font></td></tr>
    <?php 
    }
    ?>
      <tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Fecha de devoluciĆ³n</font>
       </td>
       <td class="DataTD">
         <font class="DataFONT"><input type="hidden" name="PRES_FECH_DEVO" maxlength="15" value="<?php 
    echo tohtml($fldPRES_FECH_DEVO);
    ?>
" size="15" ><?php 
    echo $fldPRES_FECH_DEVO;
    ?>
</font>
       </td>
     </tr>

<?php 
    //-------------------------------
    // PRESTAMO Show Event begin
    // PRESTAMO Show Event end
    //-------------------------------
    //-------------------------------
    // Load primary key and form parameters
    //-------------------------------
    if ($sPRESTAMOErr == "") {
        $rqd_PRES_ID = get_param("PRES_ID");
        $pPRES_ID = get_param("PRES_ID");
        $fldUSUA_LOGIN_ACTU = strip(strtoupper(get_param("usuario")));
    } else {
        $fldUSUA_LOGIN_PRES = strip(get_param("USUA_LOGIN_PRES"));
        $fldUSUA_LOGIN_ACTU = strip(get_param("USUA_LOGIN_ACTU"));
        $fldPRES_FECH_PRES = strip(get_param("PRES_FECH_PRES"));
        $pPRES_ID = get_param("PK_PRES_ID");
    }
    //-------------------------------
    //-------------------------------
    // Load all form fields
    //-------------------------------
    //-------------------------------
    // Build WHERE statement
    //-------------------------------
    $usuario = get_param("usuario");
    $usuario = strtoupper($usuario);
    if (!strlen($usuario)) {
        $bPK = false;
    }
    $sWhere .= "USUA_LOGIN_ACTU=" . tosql($usuario, "text") . " AND (PRES_ESTADO=2 OR PRES_ESTADO=5)";
    // Prestado = 2...
    //-------------------------------
    //-------------------------------
    // PRESTAMO Open Event begin
    // PRESTAMO Open Event end
    //-------------------------------
    //-------------------------------
    // Build SQL statement and execute query
    //-------------------------------
    $radiATexto = $db->conn->numToString("RADI_NUME_RADI");
    $sSQL = "select PRES_ID,\n\t\t\t{$radiATexto} as RADI_NUME_RADI,\n\t\t\tUSUA_LOGIN_ACTU,\n\t\t\tDEPE_CODI,\n\t\t\tUSUA_LOGIN_PRES,\n\t\t\tPRES_DESC,\n\t\t\tPRES_FECH_PRES,\n\t\t\tPRES_FECH_DEVO,\n\t\t\tPRES_FECH_PEDI,\n\t\t\tPRES_ESTADO,\n\t\t\tPRES_REQUERIMIENTO,\n\t\t\tPRES_DEPE_ARCH,\n\t\t\tPRES_FECH_VENC\n   from PRESTAMO where " . $sWhere;
    // Execute SQL statement
    $db->conn->SetFetchMode(ADODB_FETCH_ASSOC);
    $rs = $db->query($sSQL);
    $db->conn->SetFetchMode(ADODB_FETCH_NUM);
    //-------------------------------
    //-------------------------------
    // Load lists of values
    //-------------------------------
    $aPRES_REQUERIMIENTO = split(";", "1;Documento;2;Anexo");
    //-------------------------------
    //-------------------------------
    // Load all fields into variables from recordset or input parameters
    //-------------------------------
    $contador = 0;
    while ($bPK && ($rs && !$rs->EOF)) {
        $contador++;
        $fldDEPE_CODI = $rs->fields["DEPE_CODI"];
        $fldPRES_FECH_PEDI = $rs->fields["PRES_FECH_PEDI"];
        $fldPRES_FECH_VENC = $rs->fields["PRES_FECH_VENC"];
        $fldPRES_ID = $rs->fields["PRES_ID"];
        $fldPRES_REQUERIMIENTO = $rs->fields["PRES_REQUERIMIENTO"];
        $fldRADI_NUME_RADI = $rs->fields["RADI_NUME_RADI"];
        $fldUSUA_LOGIN_ACTU = $rs->fields["USUA_LOGIN_ACTU"];
        //-------------------------------
        // Load data from recordset when form displayed first time
        //-------------------------------
        if ($sPRESTAMOErr == "") {
            $fldUSUA_LOGIN_PRES = $rs->fields["USUA_LOGIN_PRES"];
            $fldPRES_FECH_PRES = $rs->fields["PRES_FECH_PRES"];
            $fldPRES_DESC = $rs->fields["PRES_DESC"];
            $fldPRES_ESTADO = $rs->fields["PRES_ESTADO"];
        } else {
            $fldPRES_DESC = strip(get_param("PRES_DESC_" . $contador));
            $fldPRES_ESTADO = strip(get_param("PRES_ESTADO_" . $contador));
            $fldPRES_ID = strip(get_param("PRES_ID_" . $contador));
        }
        //-------------------------------
        // Set lookup fields
        //-------------------------------
        $fldDEPE_CODI = get_db_value("SELECT DEPE_NOMB FROM DEPENDENCIA WHERE DEPE_CODI=" . tosql($fldDEPE_CODI, "Number"));
        //-------------------------------
        // Show form field
        //-------------------------------
        ?>

<tr><td colspan="2"><HR></td></tr>
	<tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Radicado</font>
       </td>
       <td class="DataTD">
         <font class="DataFONT">
      <?php 
        echo tohtml($fldRADI_NUME_RADI);
        ?>
&nbsp;</font>
       </td>
     </tr>
      <tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Fecha de Vencimiento</font>
       </td>
       <td class="DataTD">
         <font class="DataFONT"><?php 
        echo $fldPRES_FECH_VENC;
        ?>
</font>
       </td>
     </tr>
      <tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Requerimiento</font>
       </td>
       <td class="DataTD">
         <font class="DataFONT">
      <?php 
        $fldPRES_REQUERIMIENTO = get_lov_value($fldPRES_REQUERIMIENTO, $aPRES_REQUERIMIENTO);
        ?>
      <?php 
        echo tohtml($fldPRES_REQUERIMIENTO);
        ?>
&nbsp;</font>
       </td>
     </tr>
      <tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Observaciones extras</font>
       </td>
       <td class="DataTD"><?php 
        $nombreCampo = "PRES_DESC_" . $contador;
        ?>
         <font class="DataFONT"><textarea name="<?php 
        echo $nombreCampo;
        ?>
" cols="50" rows="5"><?php 
        echo tohtml($fldPRES_DESC);
        ?>
</textarea></font>
       </td>
     </tr>
      <tr>
       <td class="FieldCaptionTD">
         <font class="FieldCaptionFONT">Estado</font>
       </td>
       <td class="DataTD"><?php 
        $nombreCampo = "PRES_ESTADO_" . $contador;
        ?>
         <font class="DataFONT"><select name="<?php 
        echo $nombreCampo;
        ?>
">
<?php 
        $LOV = split(";", "3;Devolver;1;No hacer nada;");
        if (sizeof($LOV) % 2 != 0) {
            $array_length = sizeof($LOV) - 1;
        } else {
            $array_length = sizeof($LOV);
        }
        for ($i = 0; $i < $array_length; $i = $i + 2) {
            if ($LOV[$i] == $fldPRES_ESTADO) {
                $option = "<option SELECTED value=\"" . $LOV[$i] . "\">" . $LOV[$i + 1];
            } else {
                $option = "<option value=\"" . $LOV[$i] . "\">" . $LOV[$i + 1];
            }
            echo $option;
        }
        ?>
</select></font>
       </td>
     </tr>

<?php 
        $nombreCampo = "PRES_ID_" . $contador;
        ?>
  <input type="hidden" name="<?php 
        echo $nombreCampo;
        ?>
" value="<?php 
        echo tohtml($fldPRES_ID);
        ?>
">
<?php 
        $rs->MoveNext();
    }
    if ($contador == 0) {
        ?>
	<tr><td colspan="2"><HR></td></tr>
	<tr><td colspan="2"><font class="DataFONT">No hay documentos para prestar</font></td></tr>
<?php 
    }
    ?>

    <tr><td colspan="2" align="right">
<?php 
    if ($bPK && $contador != 0) {
        ?>
  <input type="hidden" value="update" name="FormAction"/>
  <input type="submit" value="Devolver/Cancelar" onclick="document.PRESTAMO.FormAction.value = 'update';">
<?php 
    }
    ?>
  <input type="submit" value="No hacer nada" onclick="document.PRESTAMO.FormAction.value = 'cancel';">
  <input type="hidden" name="FormName" value="DEVOLVER">
  <input type="hidden" name="NumContador" value="<?php 
    echo $contador;
    ?>
">
  
  </td></tr>
  </form>
  </table>
<?php 
    //-------------------------------
    // PRESTAMO Close Event begin
    // PRESTAMO Close Event end
    //-------------------------------
    //-------------------------------
    // PRESTAMO Show end
    //-------------------------------
}
Example #7
0
include_once 'include/functions_user.php';
$get_group_details = (bool) get_parameter('get_group_details');
$id = (int) get_parameter('id');
$delete_user = get_parameter('delete_user', 0);
if ($delete_user) {
    $id_user_delete = get_parameter('id_user_delete');
    user_delete_user($id_user_delete);
}
if ($get_group_details) {
    if (!give_acl($config["id_user"], $id, "IR")) {
        return;
    }
    $default_user = get_db_value('id_user_default', 'tgrupo', 'id_grupo', $id);
    $real_name = get_db_value('nombre_real', 'tusuario', 'id_usuario', $default_user);
    $group = array();
    $group['forced_email'] = get_db_value('forced_email', 'tgrupo', 'id_grupo', $id);
    $group['user_real_name'] = $real_name;
    $group['id_user_default'] = $default_user;
    echo json_encode($group);
    if (defined('AJAX')) {
        return;
    }
}
if (!give_acl($config["id_user"], 0, "UM")) {
    audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access group management");
    require "general/noaccess.php";
    exit;
}
echo '<h1>' . __('Group management') . '</h1>';
$create_group = (bool) get_parameter('create_group');
$update_group = (bool) get_parameter('update_group');
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

global $config;

check_login ();

require_once ('include/functions_inventories.php');
require_once ('include/functions_user.php');

$id = (int) get_parameter ('id');
$inventory_name = get_db_value('name', 'tinventory', 'id', $id);


$is_enterprise = false;

if (file_exists ("enterprise/include/functions_inventory.php")) {
	require_once ("enterprise/include/functions_inventory.php");
	$is_enterprise = true;
}

$write_permission = true;

if ($is_enterprise) {
	$read_permission = inventory_check_acl($config['id_user'], $id);

	$write_permission = inventory_check_acl($config['id_user'], $id, true);
function calendar_get_users_holidays_date_range($start, $end, $id_user)
{
    $mysql_start = date('Y-m-d', $start);
    $mysql_end = date('Y-m-d', $end);
    $user_clause = "";
    if (is_array($id_user)) {
        $aux_ids = array();
        foreach ($id_user as $iu) {
            array_push($aux_ids, "'" . $iu . "'");
        }
        $user_clause = "id_user IN (" . join(",", $aux_ids) . ")";
    } else {
        $user_clause = "id_user = '******'";
    }
    $sql = sprintf("SELECT tworkunit.timestamp AS date, tworkunit.id_user as user FROM tworkunit, tworkunit_task WHERE \n\t\t\t\t\t{$user_clause} AND tworkunit_task.id_workunit = tworkunit.id AND tworkunit_task.id_task =-1 AND \n\t\t\t\t\ttimestamp >= '{$mysql_start}' AND timestamp <= '{$mysql_end}' ORDER BY date ASC");
    $res = process_sql($sql);
    if (!$res) {
        $res = array();
    }
    $holidays = array();
    $holidays_counters = array();
    $holidays_last_day = array();
    foreach ($res as $r) {
        if (!isset($holidays[$r["user"]])) {
            $holidays[$r["user"]] = array();
            $holidays_counters[$r["user"]] = -1;
            $holidays_last_day[$r["user"]] = 0;
        }
        //Calculate start and end for the holiday value
        if (isset($holidays_last_day[$r["user"]])) {
            //Last day minus current day is 1 we increase dates for stored holidays
            $last_time = strtotime($holidays_last_day[$r["user"]]);
            $current_time = strtotime($r["date"]);
            $day_in_seconds = 24 * 3600;
            if ($current_time - $last_time <= $day_in_seconds) {
                $pos = $holidays_counters[$r["user"]];
                $holidays[$r["user"]][$pos]["end"] = strtotime($r["date"]);
                $holidays_last_day[$r["user"]] = strtotime($r["date"]);
            } else {
                array_push($holidays[$r["user"]], array("start" => strtotime($r["date"]), "end" => strtotime($r["date"])));
                $holidays_last_day[$r["user"]] = $r["date"];
                $holidays_counters[$r["user"]]++;
            }
        }
        //Update last day
        $holidays_last_day[$r["user"]] = $r["date"];
    }
    $full_holidays = array();
    $colors = array("#aa3333", "#33aa33", "#3a3a3a", "#3333aa", "#045FB4", "#DF7401", "#01DF3A", "#BE81F7", "#8181F7", "#81BEF7", "#F781F3", "#F7D358", "#F78181", "#FA8258", "#BCF5A9", "#A9A9F5", "#D0A9F5", "#E2A9F3", "#A9F5D0", "#A9F5E1", "#BDBDBD", "#E6E6E6", "#F6CECE", "#6AA4B2", "#6AB277", "#B28E6A", "#B26A97", "#776AB2", "#A58EB4", "#8EB490", "#8E96B4", "#B48E98");
    $i = 0;
    $colors_size = count($colors);
    foreach ($holidays as $key => $values) {
        $i = $i % $colors_size;
        $name = get_db_value("nombre_real", "tusuario", "id_usuario", $key);
        $url = "index.php?sec=users&sec2=operation/user_report/holidays_calendar&custom_dates=1&id_user="******"name" => safe_output($name), "dates" => $values, "bgColor" => $colors[$i], "link" => $url));
        $i++;
    }
    return $full_holidays;
}
Example #10
0
function dlookup($table_name, $field_name, $where_condition)
{
    $sql = "SELECT " . $field_name . " FROM " . $table_name . " WHERE " . $where_condition;
    return get_db_value($sql);
}
Example #11
0
    $table_advanced->data[3][1] .= "<img src='images/task.png'></a>";
} else {
    $table_advanced->data[3][1] .= "&nbsp;&nbsp;<a id='task_link' title='" . __('Open this task') . "' target='_blank' href='javascript:;'></a>";
}
$table_advanced->data[1][1] = print_input_text('email_copy', $email_copy, "", 70, 500, true, __("Additional email addresses"), $blocked_incident);
if (!$blocked_incident) {
    $table_advanced->data[1][1] .= "&nbsp;&nbsp;<a href='javascript: incident_show_contact_search();'>" . print_image('images/add.png', true, array('title' => __('Add'))) . "</a>";
}
if ($create_incident) {
    $id_inventory = (int) get_parameter('id_inventory');
    $inventories = array();
    if ($id_inventory) {
        if (!give_acl($config['id_user'], $id_inventory, "VR")) {
            audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access inventory #" . $id);
        } else {
            $inventories[$id_inventory] = get_db_value('name', 'tinventory', 'id', $id_inventory);
        }
    }
    $table_advanced->data[3][2] = print_select($inventories, 'incident_inventories', NULL, '', '', '', true, false, false, __('Objects affected'));
    $table_advanced->data[3][2] .= "&nbsp;&nbsp;<a href='javascript: incident_show_inventory_search(\"\",\"\",\"\",\"\",\"\",\"\");'>" . print_image('images/add.png', true, array('title' => __('Add'))) . "</a>";
    $table_advanced->data[3][2] .= "&nbsp;&nbsp;<a href='javascript: removeInventory();'>" . print_image('images/cross.png', true, array('title' => __('Remove'))) . "</a>";
} else {
    $inventories = get_inventories_in_incident($id);
    $table_advanced->data[3][2] = print_select($inventories, 'incident_inventories', NULL, '', '', '', true, false, false, __('Objects affected'), $blocked_incident);
    if (!$blocked_incident) {
        $table_advanced->data[3][2] .= "&nbsp;&nbsp;<a href='javascript: incident_show_inventory_search(\"\",\"\",\"\",\"\",\"\",\"\");'>" . print_image('images/add.png', true, array('title' => __('Add'))) . "</a>";
        $table_advanced->data[3][2] .= "&nbsp;&nbsp;<a href='javascript: removeInventory();'>" . print_image('images/cross.png', true, array('title' => __('Remove'))) . "</a>";
    }
}
foreach ($inventories as $inventory_id => $inventory_name) {
    $table_advanced->data[3][2] .= print_input_hidden("inventories[]", $inventory_id, true, 'selected-inventories');
Example #12
0
        $old_name = get_db_value("name", "tinventory", "id", $inventory_id);
    }
    // Checks if the name is in the db
    $query_result = get_db_value("name", "tinventory", "name", $name);
    if ($query_result) {
        if ($name != $old_name) {
            // Exists. Validation error
            echo json_encode(false);
            return;
        }
    }
    // Does not exist
    echo json_encode(true);
    return;
}
if ($search_duplicate_name) {
    if (!isset($config['duplicate_inventory_name']) || $config['duplicate_inventory_name']) {
        echo json_encode(true);
        return;
    } else {
        $inventory_name = get_parameter('inventory_name');
        $exists = get_db_value('id', 'tinventory', 'name', $inventory_name);
        if ($exists) {
            echo json_encode(false);
            return;
        } else {
            echo json_encode(true);
            return;
        }
    }
}
Example #13
0
function combo_roles_people_task($id_task, $id_user, $label = '', $return = false)
{
    $roles = get_db_all_rows_filter('trole_people_task', array('id_task' => $id_task, 'id_user' => $id_user), 'id_role');
    $user_roles = array();
    $output = '';
    if ($roles !== false) {
        foreach ($roles as $key => $rol) {
            $rol_name = get_db_value('name', 'trole', 'id', $rol['id_role']);
            $user_roles[$rol['id_role']] = $rol_name;
        }
    }
    return print_select($user_roles, 'id_profile', '', '', 0, 0, true, 0, false, $label);
}
$incident_adv_details .= "</tr>";
$incident_adv_details .= "<tr>";
$incident_adv_details .= "<td class='advanced_details_icons'>" . print_image('images/sla.png', true) . "</td>";
$incident_adv_details .= "<td><table><tr><td>" . __("SLA disabled") . ":</td><td align='right'><b>" . $sla . "</b></td></tr></table></td>";
$incident_adv_details .= "</tr>";
$incident_adv_details .= "<tr>";
$incident_adv_details .= $obj_table;
$incident_adv_details .= "<tr>";
$incident_adv_details .= "<td class='advanced_details_icons'>" . print_image('images/email.png', true) . "</td>";
$incident_adv_details .= "<td><table><tr><td>" . __("Notify changes by email") . ":</td><td align='right'><b>" . $email_notify_text . "</b></td></tr></table></td>";
$incident_adv_details .= "</tr>";
$incident_adv_details .= $email_table;
$incident_adv_details .= "</table>";
$left_side .= print_container('incident_adv_details', __('Advanced details'), $incident_adv_details);
if ($incident["id_incident_type"]) {
    $type_name = get_db_value("name", "tincident_type", "id", $incident["id_incident_type"]);
    $incident_custom_fields = "<table class='advanced_details_table alternate'>";
    $incident_custom_fields .= "<tr>";
    $incident_custom_fields .= "<td><table><tr><td><b>" . $type_name . "</b></td></tr></table></td>";
    $incident_custom_fields .= "</tr>";
    $fields = incidents_get_all_type_field($incident["id_incident_type"], $id);
    foreach ($fields as $f) {
        if ($f["type"] != "textarea") {
            $incident_custom_fields .= "<tr>";
            $incident_custom_fields .= "<td>";
            $incident_custom_fields .= "<table>";
            $incident_custom_fields .= "<tr>";
            $incident_custom_fields .= "<td>" . $f["label"] . ":</td><td align='right'><b>" . $f["data"] . "</b></td>";
            $incident_custom_fields .= "</tr>";
            $incident_custom_fields .= "</table>";
            $incident_custom_fields .= "</td>";
Example #15
0
	process_sql ($sql);
	echo ui_print_success_message (__('Successfully reactivated'), '', true, 'h3', true);
	audit_db ($config['id_user'], $REMOTE_ADDR, "Project activated", "User ".$config['id_user']." activated project #".$id_project);
	project_tracking ($id_project, PROJECT_ACTIVATED);
}

// Delete
if ($delete_project) {
	
	if (!$project_permission['manage']) {
		audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Forbidden", "User ".$config['id_user']." try to delete project #$id_project");
		require ("general/noaccess.php");
		exit;
	}
	
	$id_owner = get_db_value ('id_owner', 'tproject', 'id', $id_project);
	delete_project ($id_project);
	echo ui_print_success_message (__('Successfully deleted'), '', true, 'h3', true);
}

if ($view_disabled) {
	echo '<h2>'.__('Projects').'</h2>';
	echo '<h4>'.__('Archived projects');
	echo integria_help ("archieved_projects", true);
	echo '</h4>';
}

$table = new stdClass;
$table->class = 'search-table';
$table->style = array ();
$table->data = array ();
Example #16
0
	$table->width = '100%';
	$table->head = array ();
	$table->head[0] = __('ID');
	$table->head[1] = __('Name');
	$table->head[2] = __('Group');
	$table->head[3] = __('Status');
	$table->head[4] = __('Creator');
	$table->head[5] = __('Owner');
	$table->size = array ();
	$table->size[0] = '40px';
	$table->data = array();
	
	$data = array();
	foreach ($incidents as $incident) {
		//Print incident link if not ajax, if ajax link to js funtion to replace parent
		$link = "index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=".$incident["id_incidencia"];
		$data[0] = '<strong><a href="'.$link.'">#'.$incident['id_incidencia'].'</a></strong>';
		$data[1] = '<strong><a href="'.$link.'">'.$incident['titulo'].'</a></strong>';
		$data[2] = get_db_value ("nombre", "tgrupo", "id_grupo", $incident['id_grupo']);
		$data[3] = get_db_value ("name", "tincident_status", "id", $incident['estado']);
		$data[4] = $incident['id_creator'];
		$data[5] = $incident['id_usuario'];
		array_push($table->data, $data);
	}
	
	print_table ($table);
}


?>
Example #17
0
function project_tree($id_project, $id_user)
{
    include "../include/config.php";
    $config["id_user"] = $id_user;
    if (user_belong_project($id_user, $id_project) == 0) {
        audit_db($id_user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to access to task manager of unauthorized project");
        include $config["homedir"] . "/general/noaccess.php";
        exit;
    }
    if ($id_project != -1) {
        $project_name = get_db_value("name", "tproject", "id", $id_project);
    } else {
        $project_name = "";
    }
    $dotfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.dot";
    $pngfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.project.png";
    $dotfile = fopen($dotfilename, "w");
    $total_task = 0;
    $sql2 = "SELECT * FROM ttask WHERE id_project = {$id_project}";
    if ($result2 = mysql_query($sql2)) {
        while ($row2 = mysql_fetch_array($result2)) {
            if (user_belong_task($id_user, $row2["id"]) == 1) {
                $task[$total_task] = $row2["id"];
                $task_name[$total_task] = $row2["name"];
                $task_parent[$total_task] = $row2["id_parent_task"];
                $task_workunit[$total_task] = get_task_workunit_hours($row2["id"]);
                $total_task++;
            }
        }
    }
    fwrite($dotfile, "digraph Integria {\n");
    fwrite($dotfile, "\t  ranksep=2.0;\n");
    fwrite($dotfile, "\t  ratio=auto;\n");
    fwrite($dotfile, "\t  size=\"9,12\";\n");
    fwrite($dotfile, "\t  node[fontsize=" . $config['fontsize'] . "];\n");
    fwrite($dotfile, '	  project [label="' . wordwrap($project_name, 12, '\\n') . '",shape="ellipse", style="filled", color="grey"];' . "\n");
    for ($ax = 0; $ax < $total_task; $ax++) {
        fwrite($dotfile, 'TASK' . $task[$ax] . ' [label="' . wordwrap($task_name[$ax], 12, '\\n') . '"];');
        fwrite($dotfile, "\n");
    }
    // Make project first parent task relation visible
    for ($ax = 0; $ax < $total_task; $ax++) {
        if ($task_parent[$ax] == 0) {
            fwrite($dotfile, 'project -> TASK' . $task[$ax] . ';');
            fwrite($dotfile, "\n");
        }
    }
    // Make task-subtask parent task relation visible
    for ($ax = 0; $ax < $total_task; $ax++) {
        if ($task_parent[$ax] != 0) {
            fwrite($dotfile, 'TASK' . $task_parent[$ax] . ' -> TASK' . $task[$ax] . ';');
            fwrite($dotfile, "\n");
        }
    }
    fwrite($dotfile, "}");
    fwrite($dotfile, "\n");
    // exec ("twopi -Tpng $dotfilename -o $pngfilename");
    exec("twopi -Tpng {$dotfilename} -o {$pngfilename}");
    Header('Content-type: image/png');
    $imgPng = imageCreateFromPng($pngfilename);
    imageAlphaBlending($imgPng, true);
    imageSaveAlpha($imgPng, true);
    imagePng($imgPng);
    //unlink ($pngfilename);
    //unlink ($dotfilename);
}
Example #18
0
		$table->head[7] = __('Delete');
		
		foreach ($slas as $sla) {
			$data = array ();
			
			$data[0] = "<a href='index.php?sec=incidents&sec2=operation/slas/sla_detail&id=".$sla['id']."'>".$sla['name']."</a>";
			$data[1] = incidents_hours_to_dayminseg($sla['min_response']);
			$data[2] = incidents_hours_to_dayminseg($sla['max_response']);
			$data[3] = $sla['max_incidents'];
			$data[4] = incidents_hours_to_dayminseg($sla['max_inactivity']);
			
			if ($sla['enforced'] == 1)
				$data[5] = __("Yes");
			else
				$data[5] = __("No");
			$data[6] = get_db_value ('name', 'tsla', 'id', $sla['id_sla_base']);
			$data[7] = '<a href="index.php?sec=incidents&
						sec2=operation/slas/sla_detail&
						delete_sla=1&id='.$sla['id'].'"
						onClick="if (!confirm(\''.__('Are you sure?').'\'))
						return false;">
						<img src="images/cross.png"></a>';
			array_push ($table->data, $data);
		}
		echo "<div class='divresult'>";
			print_table ($table);
		echo "</div>";
	}
}
?>
Example #19
0
}
include_once "include/functions_objects.php";
//**********************************************************************
// Get actions
//**********************************************************************
$id = (int) get_parameter('id');
$create = (bool) get_parameter('create');
$insert_object = (bool) get_parameter('insert_object');
$update_object = (bool) get_parameter('update_object');
$delete_object = (bool) get_parameter('delete_object');
$get_icon = (bool) get_parameter('get_icon');
//**********************************************************************
// Ajax
//**********************************************************************
if ($get_icon) {
    $icon = (string) get_db_value('icon', 'tobject_type', 'id', $id);
    if (defined('AJAX')) {
        echo $icon;
        return;
    }
}
//**********************************************************************
// Tabs
//**********************************************************************
echo '<div id="tabs">';
/* Tabs list */
echo '<ul class="ui-tabs-nav">';
echo '<li class="ui-tabs-title">' . strtoupper(__('Object management')) . '</li>';
if (!empty($id)) {
    echo '<li class="ui-tabs-selected"><a href="index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $id . '"><span>' . __('Object details') . '</span></a></li>';
    echo '<li class="ui-tabs"><a href="index.php?sec=inventory&sec2=operation/inventories/manage_objects_types_list&id=' . $id . '"><span>' . __('Fields') . '</span></a></li>';
Example #20
0
function Ciudadano_show($nivelus, $tpRemDes, $whereFlds)
{
    //-------------------------------
    // Initialize variables
    //-------------------------------
    global $db2;
    global $db3;
    global $sRADICADOErr;
    global $sFileName;
    global $styles;
    global $ruta_raiz;
    $sWhere = "";
    $sOrder = "";
    $sSQL = "";
    $db = new ConnectionHandler($ruta_raiz);
    if ($tpRemDes == 1) {
        $tpRemDesNombre = "Por Ciudadano";
    }
    if ($tpRemDes == 2) {
        $tpRemDesNombre = "Por Otras Empresas";
    }
    if ($tpRemDes == 3) {
        $tpRemDesNombre = "Por Entidad";
    }
    if ($tpRemDes == 4) {
        $tpRemDesNombre = "Por Funcionario";
    }
    if ($tpRemDes == 9) {
        $tpRemDesNombre = "";
        $whereTrd = "   ";
    } else {
        $whereTrd = " and dir.sgd_trd_codigo = {$whereFlds}  ";
    }
    if ($indiVinculo == 2) {
        $sFormTitle = "Expedientes encontrados {$tpRemDesNombre}";
    } else {
        $sFormTitle = "Radicados encontrados {$tpRemDesNombre}";
    }
    $HasParam = false;
    $iRecordsPerPage = 25;
    $iCounter = 0;
    $iPage = 0;
    $bEof = false;
    $iSort = "";
    $iSorted = "";
    $sDirection = "";
    $sSortParams = "";
    $iTmpI = 0;
    $iTmpJ = 0;
    $sCountSQL = "";
    $transit_params = "";
    //Proceso de Vinculacion documentos
    $indiVinculo = get_param("indiVinculo");
    $verrad = get_param("verrad");
    $carpeAnt = get_param("carpeAnt");
    $nomcarpeta = get_param("nomcarpeta");
    //
    //$db->conn->debug=true;
    //-------------------------------
    // Build ORDER BY statement
    //-------------------------------
    //$sOrder = " order by r.RADI_NUME_RADI ";
    $sOrder = " order by r.radi_fech_radi ";
    $iSort = get_param("FormCIUDADANO_Sorting");
    $iSorted = get_param("FormCIUDADANO_Sorted");
    $krd = get_param("krd");
    $form_params = trim(session_name()) . "=" . trim(session_id()) . "&krd={$krd}&verrad={$verrad}&indiVinculo={$indiVinculo}&carpeAnt={$carpeAnt}&nomcarpeta={$nomcarpeta}&s_RADI_DEPE_ACTU=" . tourl(get_param("s_RADI_DEPE_ACTU")) . "&s_RADI_NOMB=" . tourl(get_param("s_RADI_NOMB")) . "&s_RADI_NUME_RADI=" . tourl(get_param("s_RADI_NUME_RADI")) . "&s_TDOC_CODI=" . tourl(get_param("s_TDOC_CODI")) . "&s_desde_dia=" . tourl(get_param("s_desde_dia")) . "&s_desde_mes=" . tourl(get_param("s_desde_mes")) . "&s_desde_ano=" . tourl(get_param("s_desde_ano")) . "&s_hasta_dia=" . tourl(get_param("s_hasta_dia")) . "&s_hasta_mes=" . tourl(get_param("s_hasta_mes")) . "&s_hasta_ano=" . tourl(get_param("s_hasta_ano")) . "&s_solo_nomb=" . tourl(get_param("s_solo_nomb")) . "&s_ciudadano=" . tourl(get_param("s_ciudadano")) . "&s_empresaESP=" . tourl(get_param("s_empresaESP")) . "&s_oEmpresa=" . tourl(get_param("s_oEmpresa")) . "&s_FUNCIONARIO=" . tourl(get_param("s_FUNCIONARIO")) . "&s_entrada=" . tourl(get_param("s_entrada")) . "&s_salida=" . tourl(get_param("s_salida")) . "&nivelus={$nivelus}&s_Listado=" . get_param("s_Listado") . "&s_SGD_EXP_SUBEXPEDIENTE=" . get_param("s_SGD_EXP_SUBEXPEDIENTE") . "&";
    // s_Listado s_ciudadano s_empresaESP s_FUNCIONARIO
    if (!$iSort) {
        $form_sorting = "";
    } else {
        if ($iSort == $iSorted) {
            $form_sorting = "";
            $sDirection = " DESC ";
            $sSortParams = "FormCIUDADANO_Sorting=" . $iSort . "&FormCIUDADANO_Sorted=" . $iSort . "&";
        } else {
            $form_sorting = $iSort;
            $sDirection = "  ";
            $sSortParams = "FormCIUDADANO_Sorting=" . $iSort . "&FormCIUDADANO_Sorted=" . "&";
        }
        switch ($iSort) {
            case 1:
                $sOrder = " order by r.radi_nume_radi" . $sDirection;
                break;
            case 2:
                $sOrder = " order by r.radi_fech_radi" . $sDirection;
                break;
            case 3:
                $sOrder = " order by r.ra_asun" . $sDirection;
                break;
            case 4:
                $sOrder = " order by td.sgd_tpr_descrip" . $sDirection;
                break;
            case 5:
                $sOrder = " order by r.radi_nume_hoja" . $sDirection;
                break;
            case 6:
                $sOrder = " order by dir.sgd_dir_direccion" . $sDirection;
                break;
            case 7:
                $sOrder = " order by dir.sgd_dir_telefono" . $sDirection;
                break;
            case 8:
                $sOrder = " order by dir.sgd_dir_mail" . $sDirection;
                break;
            case 9:
                $sOrder = " order by dir.sgd_dir_nombre" . $sDirection;
                break;
            case 12:
                $sOrder = " order by dir.sgd_dir_telefono" . $sDirection;
                break;
            case 13:
                $sOrder = " order by dir.sgd_dir_direccion" . $sDirection;
                break;
            case 14:
                $sOrder = " order by dir.sgd_dir_doc" . $sDirection;
                break;
            case 17:
                $sOrder = " order by r.radi_usu_ante" . $sDirection;
                break;
            case 20:
                $sOrder = " order by r.radi_pais" . $sDirection;
                break;
            case 21:
                $sOrder = " order by diasr" . $sDirection;
                break;
            case 22:
                $sOrder = " order by dir.sgd_dir_nombre" . $sDirection;
                break;
            case 23:
                $sOrder = " order by dir.sgd_dir_nombre" . $sDirection;
                break;
            case 24:
                $sOrder = " order by dir.sgd_dir_nombre" . $sDirection;
                break;
        }
    }
    //-------------------------------
    // Encabezados HTML de las Columnas
    //-------------------------------
    if ($indiVinculo != 2) {
        ?>
        <table width="2000" border=0 cellpadding=0 cellspacing=0 class='borde_tab'> 
        <?php 
    } else {
        ?>
            <table width="200" border=0 cellpadding=0 cellspacing=0 class='borde_tab'>
            <?php 
    }
    ?>
            <tr>
                <td class="titulos4" colspan="20"><a name="RADICADO"><?php 
    echo $sFormTitle;
    ?>
</a></td>
            </tr>
            <tr>
                <?php 
    if ($indiVinculo >= 1) {
        ?>
                    <td class="titulos5"><font class="ColumnFONT"> </td>
                    <?php 
    }
    if ($indiVinculo != 2) {
        ?>
                    <td class="titulos5"><a class="vinculos" href="<?php 
        echo $sFileName;
        ?>
?<?php 
        echo $form_params;
        ?>
FormCIUDADANO_Sorting=1&FormCIUDADANO_Sorted=<?php 
        echo $form_sorting;
        ?>
&">Radicado</a></td>
                    <td class="titulos5"><a class="vinculos" href="<?php 
        echo $sFileName;
        ?>
?<?php 
        echo $form_params;
        ?>
FormCIUDADANO_Sorting=2&FormCIUDADANO_Sorted=<?php 
        echo $form_sorting;
        ?>
&">Fecha radicaci&oacute;n</a></td>
                    <td class="titulos5"><font class="ColumnFONT">Expediente</td>
                <?php 
    } else {
        ?>
                    <td class="titulos5"><font class="ColumnFONT">Expediente</td>
                    <td class="titulos5"><a class="vinculos" href="<?php 
        echo $sFileName;
        ?>
?<?php 
        echo $form_params;
        ?>
FormCIUDADANO_Sorting=1&FormCIUDADANO_Sorted=<?php 
        echo $form_sorting;
        ?>
&">Radicado vinculado al expediente</a></td>
                    <td class="titulos5"><a class="vinculos" href="<?php 
        echo $sFileName;
        ?>
?<?php 
        echo $form_params;
        ?>
FormCIUDADANO_Sorting=2&FormCIUDADANO_Sorted=<?php 
        echo $form_sorting;
        ?>
&">Fecha Radicacion</a></td>
                <?php 
    }
    ?>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=3&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Asunto</a></td>
                <td class="titulos5"><span class="vinculos">Cuenta I.</span></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=4&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Tipo de documento</a></td>
                <td class="titulos5"><font class="ColumnFONT">Tipo</td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=5&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">N&uacute;mero de hojas</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=6&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Direcci&oacute;n contacto</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=7&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Tel&eacute;fono contacto</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=8&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Mail contacto</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=23&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Dignatario</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=9&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Nombre </a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=14&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Documento</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=15&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Usuario actual</a></td>
                <td class="titulos5"><font class="ColumnFONT">Dependencia actual</td>
                <td class="titulos5"><font class="ColumnFONT">Usuario anterior</td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=20&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">Pa&iacute;s</a></td>
                <td class="titulos5"><a class="vinculos" href="<?php 
    echo $sFileName;
    ?>
?<?php 
    echo $form_params;
    ?>
FormCIUDADANO_Sorting=21&FormCIUDADANO_Sorted=<?php 
    echo $form_sorting;
    ?>
&">D&iacute;as Restantes</a></td>

            </tr>
            <?php 
    //---------------------------------------------------------------
    // Build WHERE statement
    //-------------------------------
    // Se crea la $ps_desde_RADI_FECH_RADI con los datos ingresados.
    //---------------------------------------------------------------
    $ps_desde_RADI_FECH_RADI = mktime(0, 0, 0, get_param("s_desde_mes"), get_param("s_desde_dia"), get_param("s_desde_ano"));
    $ps_hasta_RADI_FECH_RADI = mktime(23, 59, 59, get_param("s_hasta_mes"), get_param("s_hasta_dia"), get_param("s_hasta_ano"));
    if (strlen($ps_desde_RADI_FECH_RADI) && strlen($ps_hasta_RADI_FECH_RADI)) {
        $HasParam = true;
        $sWhere = $sWhere . $db->conn->SQLDate('Y-m-d', 'r.radi_fech_radi') . " >= " . $db->conn->DBDate($ps_desde_RADI_FECH_RADI);
        //$sWhere = $sWhere . "r.radi_fech_radi>=".$db->conn->DBTimeStamp($ps_desde_RADI_FECH_RADI) ; //by HLP.
        $sWhere .= " and ";
        $sWhere = $sWhere . $db->conn->SQLDate('Y-m-d', 'r.radi_fech_radi') . " <= " . $db->conn->DBDate($ps_hasta_RADI_FECH_RADI);
        //$sWhere = $sWhere . "r.radi_fech_radi<=".$db->conn->DBTimeStamp($ps_hasta_RADI_FECH_RADI); //by HLP.
    }
    /* Se recibe la dependencia actual para bsqueda */
    $ps_RADI_DEPE_ACTU = get_param("s_RADI_DEPE_ACTU");
    if (is_number($ps_RADI_DEPE_ACTU) && strlen($ps_RADI_DEPE_ACTU)) {
        $ps_RADI_DEPE_ACTU = tosql($ps_RADI_DEPE_ACTU, "Number");
    } else {
        $ps_RADI_DEPE_ACTU = "";
    }
    if (strlen($ps_RADI_DEPE_ACTU)) {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . "r.radi_depe_actu=" . $ps_RADI_DEPE_ACTU;
    }
    /* Se recibe el nmero del radicado para bsqueda */
    require_once "../include/query/busqueda/busquedaPiloto1.php";
    $ps_RADI_NUME_RADI = get_param("s_RADI_NUME_RADI");
    $ps_DOCTO = get_param("s_DOCTO");
    if (strlen($ps_RADI_NUME_RADI)) {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . "{$radi_nume_radi} like " . tosql("%" . trim($ps_RADI_NUME_RADI) . "%", "Text");
    }
    if (strlen($ps_DOCTO)) {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . " dir.SGD_DIR_DOC = '{$ps_DOCTO}' ";
    }
    /**
     * Se recibe el nļæ½mero del expediente para bļæ½squeda
     * Fecha de modificaciļæ½n: 30-Junio-2006
     * Modificador: Supersolidaria
     */
    $ps_SGD_EXP_SUBEXPEDIENTE = get_param("s_SGD_EXP_SUBEXPEDIENTE");
    if (strlen($ps_SGD_EXP_SUBEXPEDIENTE) != 0) {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . " R.RADI_NUME_RADI = EXP.RADI_NUME_RADI";
        $sWhere = $sWhere . " AND EXP.SGD_EXP_NUMERO = SEXP.SGD_EXP_NUMERO";
        /**
         * No se tienen en cuenta los radicados que han sido excluidos de un expediente.
         * Fecha de modificaciļæ½n: 12-Septiembre-2006
         * Modificador: Supersolidaria
         */
        $sWhere = $sWhere . " AND EXP.SGD_EXP_ESTADO <> 2";
        $sWhere = $sWhere . " AND ( EXP.SGD_EXP_NUMERO LIKE '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%'";
        $sWhere = $sWhere . " OR SEXP.SGD_SEXP_PAREXP1 LIKE UPPER( '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%' )";
        $sWhere = $sWhere . " OR SEXP.SGD_SEXP_PAREXP2 LIKE UPPER( '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%' )";
        $sWhere = $sWhere . " OR SEXP.SGD_SEXP_PAREXP3 LIKE UPPER( '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%' )";
        $sWhere = $sWhere . " OR SEXP.SGD_SEXP_PAREXP4 LIKE UPPER( '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%' )";
        $sWhere = $sWhere . " OR SEXP.SGD_SEXP_PAREXP5 LIKE UPPER( '%" . str_replace('\'', '', tosql(trim($ps_SGD_EXP_SUBEXPEDIENTE), "Text")) . "%' )";
        $sWhere = $sWhere . " )";
    }
    /* Se decide si busca en radicado de entrada o de salida o ambos */
    $ps_entrada = strip(get_param("s_entrada"));
    $eLen = strlen($ps_entrada);
    $ps_salida = strip(get_param("s_salida"));
    $sLen = strlen($ps_salida);
    if ($ps_entrada != "9999") {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . "({$radi_nume_radi} like " . tosql("%" . trim($ps_entrada), "Text") . ")";
    }
    /* Se recibe el tipo de documento para la busqueda */
    $ps_TDOC_CODI = get_param("s_TDOC_CODI");
    if (is_number($ps_TDOC_CODI) && strlen($ps_TDOC_CODI) && $ps_TDOC_CODI != "9999") {
        $ps_TDOC_CODI = tosql($ps_TDOC_CODI, "Number");
    } else {
        $ps_TDOC_CODI = "";
    }
    if (strlen($ps_TDOC_CODI)) {
        if ($sWhere != "") {
            $sWhere .= " and ";
        }
        $HasParam = true;
        $sWhere = $sWhere . "r.tdoc_codi=" . $ps_TDOC_CODI;
    }
    /*             * ***************************************************************
     * Se recibe la cadena del metadato para la busqueda.
     * Implemnetacion para OPAIN S.A.
     * por Grupo Iyunxi Ltda.
     */
    $ps_METADATO = strip(get_param("s_METADATO"));
    $yaentro = false;
    if (strlen($ps_METADATO)) {
        if ($sWhere != "") {
            $sWhere .= " and MM.SGD_MMR_DATO LIKE '%{$ps_METADATO}%'";
        }
        $HasParam = true;
        $sWhere .= " ";
    }
    //****************************************************************
    /* Se recibe la caadena a buscar y el tipo de busqueda (All) (Any) */
    $ps_RADI_NOMB = trim(strip(get_param("s_RADI_NOMB")));
    $ps_RADI_NOMB = mb_strtoupper(trim($ps_RADI_NOMB), ini_get('default_charset'));
    $ps_solo_nomb = get_param("s_solo_nomb");
    $yaentro = false;
    if (trim($ps_RADI_NOMB)) {
        $inTD = ",2";
    }
    if (strlen($ps_RADI_NOMB)) {
        //&& $ps_solo_nomb == "Any")
        if ($sWhere != "") {
            $sWhere .= " and (";
        }
        $HasParam = true;
        $sWhere .= " ";
        $ps_RADI_NOMB = strtoupper($ps_RADI_NOMB);
        $tok = strtok($ps_RADI_NOMB, " ");
        $sWhere .= "(";
        while ($tok) {
            $sWhere .= "";
            if ($yaentro == true) {
                $sWhere .= " and ";
            }
            $sWhere .= "UPPER(dir.sgd_dir_nomremdes) LIKE '%" . $tok . "%' ";
            $tok = strtok(" ");
            $yaentro = true;
        }
        $sWhere .= ") or (";
        $tok = strtok($ps_RADI_NOMB, " ");
        $yaentro = false;
        while ($tok) {
            $sWhere .= "";
            if ($yaentro == true) {
                $sWhere .= " and ";
            }
            $sWhere .= "UPPER(dir.sgd_dir_nombre) LIKE '%" . $tok . "%' ";
            $tok = strtok(" ");
            $yaentro = true;
        }
        $sWhere .= ") or (";
        $yaentro = false;
        $tok = strtok($ps_RADI_NOMB, " ");
        if ($yaentro == true) {
            $sWhere .= " and (";
        }
        $sWhere .= "UPPER(" . $db->conn->Concat("r.ra_asun", "r.radi_cuentai", "dir.sgd_dir_telefono", "dir.sgd_dir_direccion") . ") LIKE '%" . $ps_RADI_NOMB . "%' ";
        $tok = strtok(" ");
        if ($yaentro == true) {
            $sWhere .= ")";
        }
        $yaentro = true;
        $sWhere .= "))";
    }
    if (strlen($ps_RADI_NOMB) && $ps_solo_nomb == "AllTTT") {
        if ($sWhere != "") {
            $sWhere .= " AND (";
        }
        $HasParam = true;
        $sWhere .= " ";
        $ps_RADI_NOMB = strtoupper($ps_RADI_NOMB);
        $tok = strtok($ps_RADI_NOMB, " ");
        $sWhere .= "(";
        $sWhere .= "";
        if ($yaentro == true) {
            $sWhere .= " AND ";
        }
        $sWhere .= "UPPER(dir.sgd_dir_nomremdes) LIKE '%" . $ps_RADI_NOMB . "%' ";
        $tok = strtok(" ");
        $yaentro = true;
        $sWhere .= ") OR (";
        $tok = strtok($ps_RADI_NOMB, " ");
        $yaentro = false;
        $sWhere .= "";
        if ($yaentro == true) {
            $sWhere .= " AND ";
        }
        $sWhere .= "UPPER(dir.sgd_dir_nombre) LIKE '%" . $ps_RADI_NOMB . "%' ";
        $tok = strtok(" ");
        $yaentro = true;
        $sWhere .= ") OR (";
        $yaentro = false;
        $tok = strtok($ps_RADI_NOMB, " ");
        if ($yaentro == true) {
            $sWhere .= " AND (";
        }
        $sWhere .= "UPPER(" . $db->conn->Concat("r.ra_asun", "r.radi_cuentai", "dir.sgd_dir_telefono", "dir.sgd_dir_direccion") . ") LIKE '%" . $ps_RADI_NOMB . "%' ";
        $tok = strtok(" ");
        if ($yaentro == true) {
            $sWhere .= ")";
        }
        $yaentro = true;
        $sWhere .= "))";
    }
    if ($HasParam) {
        $sWhere = " AND (" . $sWhere . ") ";
    }
    //-------------------------------
    // Build base SQL statement
    //-------------------------------
    require_once "../include/query/busqueda/busquedaPiloto1.php";
    $sSQL = "SELECT " . $radi_nume_radi . " AS RADI_NUME_RADI," . $db->conn->SQLDate('Y-m-d H:i:s', 'R.RADI_FECH_RADI') . " AS RADI_FECH_RADI,\n\t\t\tr.RA_ASUN, \n\t\t\tr.RADI_CUENTAI AS CUENTAI,\n\t\t\ttd.sgd_tpr_descrip, " . $redondeo . " as diasr,\n\t\t\tr.RADI_NUME_HOJA, \n\t\t\tr.RADI_PATH, \n\t\t\tdir.SGD_DIR_DIRECCION, \n\t\t\tdir.SGD_DIR_MAIL,\n\t\t\tdir.SGD_DIR_NOMREMDES, \n\t\t\tdir.SGD_DIR_TELEFONO, \n\t\t\tdir.SGD_DIR_DIRECCION,\n                        dir.SGD_DIR_DOC, \n\t\t\tr.RADI_USU_ANTE, \n\t\t\tr.RADI_PAIS,\n\t\t\tdir.SGD_DIR_NOMBRE,\n                        dir.SGD_TRD_CODIGO, \n\t\t\tr.RADI_DEPE_ACTU, \n\t\t\tr.RADI_USUA_ACTU, \n\t\t\tr.CODI_NIVEL, \n\t\t\tr.SGD_SPUB_CODIGO";
    /*             * ******************************************************************
                  /**
                 * Bļæ½squeda por parļæ½meto del expediente 
                 * Fecha de modificacion: 11-Agosto-2006
                 * Modificador: Supersolidaria
                 */
    if (strlen($ps_SGD_EXP_SUBEXPEDIENTE) != 0) {
        $sSQL .= " ,EXP.SGD_EXP_NUMERO";
    }
    /**
     * Bļæ½squeda por expediente
     * Fecha de modificaciļæ½n: 30-Junio-2006
     * Modificador: Supersolidaria
     */
    //Modificacion de la conslta para trabajar con la mejora de la busqueda por metadato - Grupo Iyunxi Ltda.
    if (strlen($ps_SGD_EXP_SUBEXPEDIENTE) != 0) {
        $sSQL .= " FROM SGD_EXP_EXPEDIENTE EXP, SGD_SEXP_SECEXPEDIENTES SEXP, RADICADO as R\n                INNER JOIN SGD_DIR_DRECCIONES DIR ON R.RADI_NUME_RADI=DIR.RADI_NUME_RADI \n\t        INNER JOIN SGD_TPR_TPDCUMENTO TD ON R.TDOC_CODI=TD.SGD_TPR_CODIGO";
    } else {
        $sSQL .= " FROM RADICADO R \n                INNER JOIN SGD_DIR_DRECCIONES DIR ON R.RADI_NUME_RADI=DIR.RADI_NUME_RADI \n\t        INNER JOIN SGD_TPR_TPDCUMENTO TD ON R.TDOC_CODI=TD.SGD_TPR_CODIGO";
    }
    /*             * **************************************************************************************
     * Busqueda por Metadato
     * Fecha de implemnetacion 11/Julio/2011
     * Para: OPAIN S.A.
     * Por: Grupo Iyunxi Ltda
     */
    if (strlen($ps_METADATO) != 0) {
        $sSQL .= " LEFT JOIN SGD_MMR_MATRIMETARADI MM ON R.RADI_NUME_RADI = MM.RADI_NUME_RADI";
    }
    /*             * ************************************************************************************** */
    $sSQL .= " WHERE dir.sgd_dir_tipo in (1{$inTD})";
    // $sSQL .= " WHERE dir.RADI_NUME_RADI=r.RADI_NUME_RADI AND r.TDOC_CODI=td.SGD_TPR_CODIGO ";
    //-------------------------------//SE QUITA " AND r.CODI_NIVEL <=$nivelus "
    //---------------------------------
    // Assemble full SQL statement
    //-------------------------------
    $sSQL .= $sWhere . $whereTrd . $sOrder;
    // echo "<!-- $sSQL -->";
    // $db->conn->debug=true;
    //-------------------------------
    // Execute SQL statement
    //-------------------------------
    $db->conn->SetFetchMode(ADODB_FETCH_ASSOC);
    // print $sSQL;
    $rs = $db->query($sSQL);
    $rsaux = $db->query($sSQL);
    $db->conn->SetFetchMode(ADODB_FETCH_NUM);
    //echo "<hr>$sSQL<hr>";
    //-------------------------------
    // Process empty recordset
    //-------------------------------
    if ($rs->EOF || !$rs) {
        ?>
                <tr>
                    <td colspan="20" class="alarmas">No hay resultados</td>
                </tr>
                <?php 
        //-------------------------------
        //  The insert link.
        //-------------------------------
        ?>
                <tr>
                    <td colspan="20" class="ColumnTD"><font class="ColumnFONT">
                        <?php 
        ?>
            </table>
            <?php 
        return;
    }
    /* else{
              if (!isset($carpetaBodega)) {
              include "$ruta_raiz/config.php";
              }
              include_once("$ruta_raiz/adodb/toexport.inc.php");
    
              $ruta = "$ruta_raiz/".$carpetaBodega."tmp/Busqclasic".date('Y_m_d_H_i_s').".csv";
              $f = fopen($ruta, 'w');
              if ($f) {
              rs2csvfile($rsaux, $f);
              $linkcsv= "<a href='$ruta' target='_blank'><img style='border:0px' src='".$ruta_raiz."imagenes/csv.png' alt='Archivo CSV'/></a>";
              }
              } */
    //-------------------------------
    ?>
        <!--tr>
         <td colspan="10" class="DataTD"><b>Total Registros Encontrados: <?php 
    echo $fldTotal;
    ?>
</b></td>
        </tr-->

        <?php 
    //-------------------------------
    // Initialize page counter and records per page
    //-------------------------------
    $iCounter = 0;
    //-------------------------------
    //-------------------------------
    // Process page scroller
    //-------------------------------
    $iPage = get_param("FormCIUDADANO_Page");
    //print ("<BR>($iPage)($iRecordsPerPage)");
    if (strlen(trim($iPage)) == 0) {
        $iPage = 1;
    } else {
        if ($iPage == "last") {
            $db_count = get_db_value($sCountSQL);
            $dResult = intval($db_count) / $iRecordsPerPage;
            $iPage = intval($dResult);
            if ($iPage < $dResult) {
                $iPage++;
            }
        } else {
            $iPage = intval($iPage);
        }
    }
    if (($iPage - 1) * $iRecordsPerPage != 0) {
        //print ("<BR>($iPage)($iRecordsPerPage)");
        do {
            $iCounter++;
            $rs->MoveNext();
            //print("Entra......");
        } while ($iCounter < ($iPage - 1) * $iRecordsPerPage && (!$rs->EOF && $rs));
    }
    $iCounter = 0;
    //-------------------------------
    //$ruta_raiz ="..";
    //include "../config.php";
    //include "../jh_class/funciones_sgd.php";
    //-------------------------------
    // Display grid based on recordset
    //-------------------------------.
    $i = 1;
    while (!$rs->EOF && $rs && $iCounter < $iRecordsPerPage) {
        //-------------------------------
        // Create field variables based on database fields
        //-------------------------------
        $fldRADI_NUME_RADI = $rs->fields['RADI_NUME_RADI'];
        $fldRADI_FECH_RADI = $rs->fields['RADI_FECH_RADI'];
        /**
         * Bļæ½squeda por expediente
         * Fecha de modificaciļæ½n: 11-Agosto-2006
         * Modificador: Supersolidaria
         */
        $fldsSGD_EXP_SUBEXPEDIENTE = $rs->fields['SGD_EXP_NUMERO'];
        $fldCUENTAI = $rs->fields['CUENTAI'];
        $fldASUNTO = $rs->fields['RA_ASUN'];
        $fldTIPO_DOC = $rs->fields['SGD_TPR_DESCRIP'];
        $fldNUME_HOJAS = $rs->fields['RADI_NUME_HOJA'];
        $fldRADI_PATH = $rs->fields['RADI_PATH'];
        $fldDIRECCION_C = $rs->fields['SGD_DIR_DIRECCION'];
        $fldDIGNATARIO = $rs->fields['SGD_DIR_NOMBRE'];
        $fldTELEFONO_C = $rs->fields['SGD_DIR_TELEFONO'];
        $fldMAIL_C = $rs->fields['SGD_DIR_MAIL'];
        $fldNOMBRE = $rs->fields['SGD_DIR_NOMREMDES'];
        $fldCEDULA = $rs->fields['SGD_DIR_DOC'];
        //$fldUSUA_ACTU = $rs->fields['NOMB_ACTU") . " - (" . $rs->fields['LOGIN_ACTU").")";
        $aRADI_DEPE_ACTU = $rs->fields['RADI_DEPE_ACTU'];
        $aRADI_USUA_ACTU = $rs->fields['RADI_USUA_ACTU'];
        $fldUSUA_ANTE = $rs->fields['RADI_USU_ANTE'];
        $fldPAIS = $rs->fields['RADI_PAIS'];
        $fldDIASR = $rs->fields['DIASR'];
        $tipoReg = $rs->fields['SGD_TRD_CODIGO'];
        $nivelRadicado = $rs->fields['CODI_NIVEL'];
        $seguridadRadicado = $rs->fields['SGD_SPUB_CODIGO'];
        $fldMETADATO = $rs->fields['SGD_MMR_DATO'];
        // Busqueda por Metadato - Grupo Iyunxi Ltda
        if ($tipoReg == 1) {
            $tipoRegDesc = "Ciudadano";
        }
        if ($tipoReg == 2) {
            $tipoRegDesc = "Empresa";
        }
        if ($tipoReg == 3) {
            $tipoRegDesc = "Entidad";
        }
        if ($tipoReg == 4) {
            $tipoRegDesc = "Funcionario";
        }
        $fldNOMBRE = str_replace($ps_RADI_NOMB, "<font color=green><b>{$ps_RADI_NOMB}</b>", tohtml($fldNOMBRE));
        $fldASUNTO = str_replace($ps_RADI_NOMB, "<font color=green><b>{$ps_RADI_NOMB}</b>", tohtml($fldASUNTO));
        //-------------------------------
        // Busquedas Anidadas
        //-------------------------------
        $queryDep = "select DEPE_NOMB from dependencia where DEPE_CODI={$aRADI_DEPE_ACTU}";
        $db->conn->SetFetchMode(ADODB_FETCH_ASSOC);
        $rs2 = $db->query($queryDep);
        $fldDEPE_ACTU = $rs2->fields['DEPE_NOMB'];
        $queryUs = "select USUA_NOMB from USUARIO where DEPE_CODI={$aRADI_DEPE_ACTU} and USUA_CODI={$aRADI_USUA_ACTU} ";
        $rs3 = $db->query($queryUs);
        $fldUSUA_ACTU = $rs3->fields['USUA_NOMB'];
        $db->conn->SetFetchMode(ADODB_FETCH_NUM);
        $linkDocto = "<a class='vinculos' href='javascript:noPermiso(0)' > ";
        $linkInfGeneral = "<a class='vinculos' href='javascript:noPermiso(0)' > ";
        if (strlen($fldRADI_PATH)) {
            $linkDoctoImg = "<a class='vinculos' href='../seguridadImagen.php?fec=" . base64_encode($fldRADI_PATH) . "' target='Imagen{$iii}'>";
        }
        $linkInfGeneralRad = "<a class='vinculos' href='../verradicado.php?verrad={$fldRADI_NUME_RADI}&" . session_name() . "=" . session_id() . "&krd={$krd}&carpeta=8&nomcarpeta=Busquedas&tipo_carp=0'>";
        if ($nivelRadicado <= $nivelus) {
            if ($seguridadRadicado == 1) {
                if ($aRADI_USUA_ACTU == $_SESSION['codusuario'] && $aRADI_DEPE_ACTU == $_SESSION['dependencia']) {
                    $linkDocto = $linkDoctoImg;
                    $linkInfGeneral = $linkInfGeneralRad;
                } else {
                    $linkDocto = "<a class='vinculos' href='javascript:noPermiso(1)' > ";
                    $linkInfGeneral = $linkInfGeneralRad;
                }
            } else {
                $linkDocto = $linkDoctoImg;
                $linkInfGeneral = $linkInfGeneralRad;
            }
        }
        if ($seguridadRadicado == 2) {
            if ($aRADI_DEPE_ACTU == $_SESSION['dependencia']) {
                $linkDocto = $linkDoctoImg;
                $linkInfGeneral = $linkInfGeneralRad;
            } else {
                $variable_inventada = $_SESSION['dependencia'];
                $linkDocto = "<a class='vinculos' href='javascript:noPermiso(1)' > ";
                $linkInfGeneral = $linkInfGeneralRad;
            }
        }
        if ($seguridadRadicado == 3) {
            $sql = "select * from sgd_matriz_nivelrad where radi_nume_radi={$fldRADI_NUME_RADI} and usua_login='******'krd'] . "'";
            $rsVerif = $db->conn->Execute($sql);
            if ($rsVerif && !$rsVerif->EOF or $aRADI_USUA_ACTU == $_SESSION['codusuario'] && $aRADI_DEPE_ACTU == $_SESSION['dependencia']) {
                $linkDocto = $linkDoctoImg;
                $linkInfGeneral = $linkInfGeneralRad;
            } else {
                $linkDocto = "<a class='vinculos' href='javascript:noPermiso(1)' > ";
                $linkInfGeneral = $linkInfGeneralRad;
            }
        }
        if ($_SESSION['usua_super_perm'] != 0) {
            //$UsrSecAux->UsrPerm
            $UsrSecAux = new SecSuperClass($db);
            $UsrSecAux->SecSuperFill($_SESSION['usua_doc']);
            if ($UsrSecAux->SecureCheck($fldRADI_NUME_RADI) == false) {
                $linkDocto = "<a class='vinculos' href='javascript:noPermiso(2)' > ";
                $linkInfGeneral = "<a class='vinculos' href='javascript:noPermiso(2)' > ";
            }
        }
        //$verImg= $verImg && !($fila['SGD_SPUB_CODIGO']==1);
        //$linkInfGeneralVin = "<a class='vinculos' href='../vinculacion/mod_vinculacion.php?numRadi=$fldRADI_NUME_RADI&carpeta=$carpeAnt&nomcarpeta=$nomcarpeta&verrad=$verrad&".session_name()."=".session_id()."&krd=$krd&carpeta=$carpeAnt&nomcarpeta=$nomcarpeta&tipo_carp=0' >";
        if (strlen($ps_SGD_EXP_SUBEXPEDIENTE) == 0) {
            $consultaExpediente = "SELECT SGD_EXP_NUMERO  FROM SGD_EXP_EXPEDIENTE\n\t\t\t\tWHERE radi_nume_radi= {$fldRADI_NUME_RADI} AND sgd_exp_fech=(SELECT MIN(SGD_EXP_FECH) as minFech from sgd_exp_expediente where radi_nume_radi= {$fldRADI_NUME_RADI})";
            $rsE = $db->query($consultaExpediente);
            $fldsSGD_EXP_SUBEXPEDIENTE = $rsE->fields[0];
        }
        //$linkInfGeneral =
        //-------------------------------
        // Process the HTML controls
        //-------------------------------
        if ($i == 1) {
            $formato = "listado1";
            $i = 2;
        } else {
            $formato = "listado2";
            $i = 1;
        }
        ?>
            <tr class="<?php 
        echo $formato;
        ?>
">
                <?php 
        if ($indiVinculo == 1) {
            ?>
                    <td class="leidos" align="center" width="70">
                        <A href="javascript:pasar_datos('<?php 
            echo $fldRADI_NUME_RADI;
            ?>
');" >
                            Vincular
                    </td>
                    <?php 
        }
        if ($indiVinculo == 2) {
            ?>
                    <td class="leidos" align="center" width="70">
                        <A href="javascript:pasar_datos('<?php 
            echo $fldsSGD_EXP_SUBEXPEDIENTE;
            ?>
',2);" >
                            Vincular
                    </td>

                    <?php 
        }
        ?>
                <td class="leidos">
                    <?php 
        if (strlen($fldRADI_PATH)) {
            $iii = $iii + 1;
            ?>
  <?php 
            echo $linkDocto;
        }
        ?>
                    <?php 
        echo $fldRADI_NUME_RADI;
        ?>
                    <?php 
        if (strlen($fldRADI_PATH)) {
            ?>
</a><?php 
        }
        ?>
&nbsp;
                </td>
                <td class="leidos"><?php 
        echo $linkInfGeneral;
        ?>
                    <?php 
        echo tohtml($fldRADI_FECH_RADI);
        ?>
&nbsp;</a></td>
                <!--
                Bļæ½squeda por expediente
                Fecha de modificaciļæ½n: 11-Agosto-2006
                Modificador: Supersolidaria
                -->
                <td class="leidos">
                    <?php 
        echo $fldsSGD_EXP_SUBEXPEDIENTE;
        ?>
&nbsp;</td>

                <td class="leidos">
                    <?php 
        echo $fldASUNTO;
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo $fldCUENTAI;
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldTIPO_DOC);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo $tipoRegDesc;
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldNUME_HOJAS);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldDIRECCION_C);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldTELEFONO_C);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldMAIL_C);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldDIGNATARIO);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo $fldNOMBRE;
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldCEDULA);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldUSUA_ACTU);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldDEPE_ACTU);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldUSUA_ANTE);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        echo tohtml($fldPAIS);
        ?>
&nbsp;</td>
                <td class="leidos">
                    <?php 
        if ($fldRADI_DEPE_ACTU != 999) {
            echo tohtml($fldDIASR);
        } else {
            echo "Sal";
        }
        ?>
&nbsp;</td>

            </tr>
            <?php 
        $iCounter++;
        $rs->MoveNext();
    }
    //-------------------------------
    //  Record navigator.
    //-------------------------------
    ?>
        <tr>
            <td colspan="20" class="ColumnTD"><font class="ColumnFONT">
                <?php 
    // Navigation begin
    $bEof = $rs;
    if ($bEof && !$bEof->EOF || $iPage != 1) {
        $iCounter = 1;
        $iHasPages = $iPage;
        $sPages = "";
        $iDisplayPages = 0;
        $iNumberOfPages = 30;
        /* El nmero de pļæ½inas que aparecerļæ½ en el navegador al pie de la pļæ½ina */
        while (!$rs->EOF && $rs && $iHasPages < $iPage + $iNumberOfPages) {
            if ($iCounter == $iRecordsPerPage) {
                $iCounter = 0;
                $iHasPages = $iHasPages + 1;
            }
            $iCounter++;
            $rs->MoveNext();
        }
        if (($rs->EOF || !$rs) && $iCounter > 1) {
            $iHasPages++;
        }
        if ($iHasPages - $iPage < intval($iNumberOfPages / 2)) {
            $iStartPage = $iHasPages - $iNumberOfPages;
        } else {
            $iStartPage = $iPage - $iNumberOfPages + intval($iNumberOfPages / 2);
        }
        if ($iStartPage < 0) {
            $iStartPage = 0;
        }
        for ($iPageCount = $iPageCount + 1; $iPageCount <= $iPage - 1; $iPageCount++) {
            $sPages .= "<a href=" . $sFileName . "?" . $form_params . $sSortParams . "FormCIUDADANO_Page=" . $iPageCount . "#RADICADO\"><font " . "class=\"ColumnFONT\"" . ">" . $iPageCount . "</a>&nbsp;";
            $iDisplayPages++;
        }
        $sPages .= "<font " . "class=\"paginacion\"" . "><b>" . $iPage . "</b>&nbsp;";
        $iDisplayPages++;
        $iPageCount = $iPage + 1;
        while ($iDisplayPages < $iNumberOfPages && $iStartPage + $iDisplayPages < $iHasPages) {
            $sPages .= "<a href=\"" . $sFileName . "?" . $form_params . $sSortParams . "FormCIUDADANO_Page=" . $iPageCount . "#RADICADO\"><font " . "class=\"ColumnFONT\"" . ">" . $iPageCount . "</a>&nbsp;";
            $iDisplayPages++;
            $iPageCount++;
        }
        if ($iPage == 1) {
            ?>
                        <font class="paginacion">Primero
                        <font class="paginacion">Anterior
                        <?php 
        } else {
            ?>
                        <a href="<?php 
            echo $sFileName;
            ?>
?<?php 
            echo $form_params;
            echo $sSortParams;
            ?>
FormCIUDADANO_Page=1#RADICADO"><font class="paginacion">Primero</a>
                        <a href="<?php 
            echo $sFileName;
            ?>
?<?php 
            echo $form_params;
            echo $sSortParams;
            ?>
FormCIUDADANO_Page=<?php 
            echo $iPage - 1;
            ?>
#RADICADO"><font class="paginacion">Anterior</a>
                        <?php 
        }
        echo "&nbsp;[&nbsp;" . $sPages . "]&nbsp;";
        if ($rs->EOF) {
            ?>
                        <font class="ColumnFONT">Siguiente
                        <font class="ColumnFONT">Ultimo
                        <?php 
        } else {
            ?>
                        <a href="<?php 
            echo $sFileName;
            ?>
?<?php 
            echo $form_params;
            echo $sSortParams;
            ?>
FormCIUDADANO_Page=<?php 
            echo $iPage + 1;
            ?>
#RADICADO"><font class="ColumnFONT">Siguiente</a>
                            <?php 
        }
    }
    ?>
            </td></tr>
    </table>
    <?php 
    if ($rsaux->EOF || !$rsaux) {
    } else {
        if (!isset($carpetaBodega)) {
            include "{$ruta_raiz}/config.php";
        }
        include_once "{$ruta_raiz}/adodb/toexport.inc.php";
        $ruta = "{$ruta_raiz}/" . $carpetaBodega . "tmp/Busqclasic" . date('Y_m_d_H_i_s') . ".csv";
        $f = fopen($ruta, 'w');
        if ($f) {
            rs2csvfile($rsaux, $f);
            echo "<a href='{$ruta}' target='_blank'><img style='border:0px' width='20' height='20' src='" . $ruta_raiz . "/imagenes/csv.png' alt='Archivo CSV'/>Archivo CSV</a>";
        }
    }
}
Example #21
0
        update_config_token("pass_expire", $config["pass_expire"]);
        update_config_token("first_login", $config["first_login"]);
        update_config_token("mins_fail_pass", $config["mins_fail_pass"]);
        update_config_token("number_attempts", $config["number_attempts"]);
    }
    echo ui_print_success_message(__('Successfully updated'), '', true, 'h3', true);
}
// Render SYSTEM language code, not current language.
$table = new StdClass();
$table->width = '100%';
$table->class = 'search-table-button';
$table->colspan = array();
$table->data = array();
$incident_reporter_options[0] = __('Disabled');
$incident_reporter_options[1] = __('Enabled');
$language_config = get_db_value('value', 'tconfig', 'token', 'language_code');
$table->data[0][0] = print_select_from_sql('SELECT id_language, name FROM tlanguage ORDER BY name', 'language_code', $language_config, '', '', '', true, false, false, __('Language'));
$table->data[0][1] = print_input_text("sitename", $config["sitename"], '', 30, 50, true, __('Sitename'));
$error_log_options[0] = __('Disabled');
$error_log_options[1] = __('Enabled');
$table->data[1][0] = print_checkbox("error_log", $error_log_options, $config["error_log"], true, __('Enable error log') . print_help_tip(__("This errorlog is on /integria.log"), true));
$table->data[1][1] = print_input_text("timezone", $config["timezone"], '', 15, 30, true, __('Timezone for integria'));
$table->data[2][0] = print_textarea("api_acl", 2, 1, $config["api_acl"], 'style="max-width: 280px;"', true, __('List of IP with access to API') . print_help_tip(__("List of IP (separated with commas which can access to the integria API. Use * for any address (INSECURE!)"), true), false);
$table->data[2][1] = print_input_password("api_password", $config["api_password"], '', 30, 255, true, __('API password'));
$days_of_week = get_days_of_week();
$table->data[4][0] = print_select($days_of_week, "first_day_week", $config["first_day_week"], '', '', '', true, 0, false, __('First day of the week'));
$table->data[4][1] = print_input_text("url_updatemanager", $config["url_updatemanager"], '', 35, 255, true, __('URL update manager'));
$table->data[5][0] = print_input_text("loginhash_pwd", $config["loginhash_pwd"], '', 30, 255, true, __('Loginhash password'));
$table->data[5][1] = print_checkbox("access_protocol", 1, $config["access_protocol"], true, __('Enable HTTPS access'));
$table->data[6][0] = print_input_text("access_port", $config["access_port"], '', 10, 255, true, __('Access port') . print_help_tip(__("Leave blank to use default port (80)"), true));
$table->data[6][1] = print_input_text("access_public", $config["access_public"], '', 30, 50, true, __('Public access to server') . print_help_tip(__("Public IP or name for the server, for example (23.45.67.3 or mydomain.com)"), true));
Example #22
0
check_login ();

// Get our main stuff
$id_project = get_parameter ("id_project", -1);
$id_task = get_parameter ("id_task", -1);


// ACL
$task_permission = get_project_access ($config["id_user"], $id_project, $id_task, false, true);
if (!$task_permission["manage"]) {
	audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access to task move without permission");
	no_permission();
}

$section_title = __('Move task to other project');
$name_task  = get_db_value ("name", "ttask", "id", $id_task);
$section_subtitle =  __('Task'). ": " . $name_task;
$t_menu = print_task_tabs();
print_title_with_menu ($section_title, $section_subtitle, "task_move", 'projects', $t_menu, 'move');

//TASK MOVE Operation
echo "<div class='divform'>";
echo "<form name='project_move' method='POST' action='index.php?sec=projects&sec2=operation/projects/task&operation=move&id_project=$id_project&id_task=$id_task'>";

echo '<table width="20%" class="search-table" >';

// Project combo
echo '<tr><td class="datos"><b>'.__('Destination project').'</b>';
combo_projects_user ($config["id_user"], 'target_project');
echo '<tr></td><td class="datos">';
echo '<input type="submit" class="sub create" name="accion" value="'.__('Move').'" border="0">';
Example #23
0
/* Help to debug problems. Override global PHP configuration */
if (!isset($develop_bypass)) {
    $develop_bypass = 0;
}
if ($develop_bypass) {
    // Develop mode, show all notices and errors on Console (and log it)
    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
        error_reporting(E_ALL & ~E_DEPRECATED);
    } else {
        error_reporting(E_ALL);
    }
    ini_set("display_errors", 1);
}
// User language selection prevails over system-wide defined language.
if (isset($_SESSION['id_usuario'])) {
    $temp = get_db_value('lang', 'tusuario', 'id_usuario', $_SESSION['id_usuario']);
    if ($temp != "") {
        $config['language_code'] = $temp;
    }
}
if (isset($_GET['language'])) {
    $config['language_code'] = $_GET['language'];
}
if (file_exists($config["homedir"] . '/include/languages/' . $config['language_code'] . '.mo')) {
    $l10n = new gettext_reader(new CachedFileReader($config["homedir"] . '/include/languages/' . $config['language_code'] . '.mo'));
    $l10n->load_tables();
}
// Set a the system timezone default
if (!isset($config["timezone"]) or $config["timezone"] == "") {
    $config["timezone"] = "Europe/Berlin";
}
Example #24
0
    $name = get_parameter("name", "");
    $description = get_parameter("description", "");
    $sql = sprintf('UPDATE tbuilding
		SET description = "%s", name = "%s" WHERE id = %d', $description, $name, $id);
    $result = process_sql($sql);
    if ($result === false) {
        echo '<h3 class="error">' . __('Building cannot be updated') . '</h3>';
    } else {
        echo '<h3 class="suc">' . __('Successfully updated') . '</h3>';
        audit_db($config["id_user"], $config["REMOTE_ADDR"], "Building", "Updated building {$id} - {$name}");
    }
    $id = 0;
}
// DELETE
if ($delete_building) {
    $name = get_db_value('name', 'tbuilding', 'id', $id);
    $sql = sprintf('DELETE FROM tbuilding WHERE id = %d', $id);
    process_sql($sql);
    audit_db($config["id_user"], $config["REMOTE_ADDR"], "Building", "Deleted building {$id} - {$name}");
    echo '<h3 class="suc">' . __('Successfully deleted') . '</h3>';
    $id = 0;
}
echo '<h2>' . __('Building management') . '</h2>';
// FORM (Update / Create)
if ($id || $new_building) {
    if ($new_building) {
        $id = 0;
        $name = "";
        $description = "";
    } else {
        $building = get_db_row('tbuilding', 'id', $id);
Example #25
0
if ($operation == "generate_email") {
	$task_participants = get_db_all_rows_sql ("SELECT direccion, nombre_real FROM tusuario, trole_people_task WHERE tusuario.id_usuario = trole_people_task.id_user AND trole_people_task.id_task = $id_task");
	$participants ="";
	foreach ($task_participants as $participant){
		$participant["direccion"];
		$text = ascii_output ($description);
		$subject = ascii_output ($title);
		integria_sendmail ($participant["direccion"], $subject, $text);
	}
	echo ui_print_success_message (__("Operation successfully completed"), '', true, 'h3', true);
}

// Get names
if ($id_project)
	$project_name = get_db_value ('name', 'tproject', 'id', $id_project);
else
	$project_name = '';

if ($id_task)
	$task = get_db_row ('ttask', 'id', $id_task);

$task_days = $task["hours"] / $config["hours_perday"];
$task_cost = $task['estimated_cost']. $config["currency"];
$prio_array = get_priorities();

$task_participants = get_db_all_rows_sql ("SELECT direccion, nombre_real FROM tusuario, trole_people_task WHERE tusuario.id_usuario = trole_people_task.id_user AND trole_people_task.id_task = $id_task");
$participants ="";
foreach ($task_participants as $participant){
	$participants .= $participant["nombre_real"]. ", ";
}
Example #26
0
function check_add_coupons($auto_apply, $new_coupon_code, &$new_coupon_error)
{
    global $db, $site_id, $table_prefix, $date_show_format;
    global $currency;
    $shopping_cart = get_session("shopping_cart");
    $order_coupons = get_session("session_coupons");
    $user_info = get_session("session_user_info");
    $user_id = get_setting_value($user_info, "user_id", "");
    $user_type_id = get_setting_value($user_info, "user_type_id", "");
    $user_tax_free = get_setting_value($user_info, "tax_free", 0);
    $user_discount_type = get_session("session_discount_type");
    $user_discount_amount = get_session("session_discount_amount");
    if (!is_array($shopping_cart) || sizeof($shopping_cart) < 1) {
        return;
    }
    // check basic product prices before any further checks
    foreach ($shopping_cart as $cart_id => $item) {
        $item_id = $item["ITEM_ID"];
        $properties_more = $item["PROPERTIES_MORE"];
        if (!$item_id || $properties_more > 0) {
            continue;
        }
        $item_type_id = $item["ITEM_TYPE_ID"];
        $properties = $item["PROPERTIES"];
        $quantity = $item["QUANTITY"];
        $tax_id = $item["TAX_ID"];
        $tax_free = $item["TAX_FREE"];
        $discount_applicable = $item["DISCOUNT"];
        $buying_price = $item["BUYING_PRICE"];
        $price = $item["PRICE"];
        $is_price_edit = $item["PRICE_EDIT"];
        $properties_price = $item["PROPERTIES_PRICE"];
        $properties_percentage = $item["PROPERTIES_PERCENTAGE"];
        $properties_buying = $item["PROPERTIES_BUYING"];
        $properties_discount = $item["PROPERTIES_DISCOUNT"];
        $components = $item["COMPONENTS"];
        if ($discount_applicable) {
            if (!$is_price_edit) {
                if ($user_discount_type == 1) {
                    $price -= round($price * $user_discount_amount / 100, 2);
                } else {
                    if ($user_discount_type == 2) {
                        $price -= round($user_discount_amount, 2);
                    } else {
                        if ($user_discount_type == 3) {
                            $price -= round($price * $user_discount_amount / 100, 2);
                        } else {
                            if ($user_discount_type == 4) {
                                $price -= round(($price - $buying_price) * $user_discount_amount / 100, 2);
                            }
                        }
                    }
                }
            }
        }
        if ($properties_percentage && $price) {
            $properties_price += round($price * $properties_percentage / 100, 2);
        }
        if ($properties_discount > 0) {
            $properties_price -= round($properties_price * $properties_discount / 100, 2);
        }
        if ($discount_applicable) {
            if ($user_discount_type == 1) {
                $properties_price -= round($properties_price * $user_discount_amount / 100, 2);
            } else {
                if ($user_discount_type == 4) {
                    $properties_price -= round(($properties_price - $properties_buying) * $user_discount_amount / 100, 2);
                }
            }
        }
        $price += $properties_price;
        // add components prices
        if (is_array($components) && sizeof($components) > 0) {
            foreach ($components as $property_id => $component_values) {
                foreach ($component_values as $property_item_id => $component) {
                    $component_price = $component["price"];
                    $component_tax_id = $component["tax_id"];
                    $component_tax_free = $component["tax_free"];
                    if ($user_tax_free) {
                        $component_tax_free = $user_tax_free;
                    }
                    $sub_item_id = $component["sub_item_id"];
                    $sub_quantity = $component["quantity"];
                    if ($sub_quantity < 1) {
                        $sub_quantity = 1;
                    }
                    $sub_type_id = $component["item_type_id"];
                    if (!strlen($component_price)) {
                        $sub_price = $component["base_price"];
                        $sub_buying = $component["buying"];
                        $sub_user_price = $component["user_price"];
                        $sub_user_action = $component["user_price_action"];
                        $sub_prices = get_product_price($sub_item_id, $sub_price, $sub_buying, 0, 0, $sub_user_price, $sub_user_action, $user_discount_type, $user_discount_amount);
                        $component_price = $sub_prices["base"];
                    }
                    // add to the item price component price
                    $price += $component_price;
                }
            }
        }
        $shopping_cart[$cart_id]["BASIC_PRICE"] = $price;
        // basic price to calculate discount amount for product coupons
        $shopping_cart[$cart_id]["DISCOUNTED_PRICE"] = $price;
        // product price with all coupon discounts
    }
    // end of product prices check
    // check if any product coupons should be removed
    $exclusive_applied = false;
    $new_coupons_total = 0;
    $coupons_total = 0;
    foreach ($shopping_cart as $cart_id => $item) {
        $item_id = $item["ITEM_ID"];
        $properties_more = $item["PROPERTIES_MORE"];
        if (!$item_id || $properties_more > 0) {
            continue;
        }
        $item_type_id = $item["ITEM_TYPE_ID"];
        $basic_price = $item["BASIC_PRICE"];
        $discounted_price = $item["DISCOUNTED_PRICE"];
        $quantity = $item["QUANTITY"];
        // product coupons
        if (isset($item["COUPONS"]) && is_array($item["COUPONS"])) {
            foreach ($item["COUPONS"] as $coupon_id => $coupon_info) {
                if ($auto_apply && $coupon_info["AUTO_APPLY"]) {
                    // always remove auto-apply coupons
                    unset($shopping_cart[$cart_id]["COUPONS"][$coupon_id]);
                } else {
                    $sql = " SELECT * FROM " . $table_prefix . "coupons ";
                    $sql .= " WHERE coupon_id=" . $db->tosql($coupon_id, INTEGER);
                    $db->query($sql);
                    if ($db->next_record()) {
                        $discount_type = $db->f("discount_type");
                        $coupon_discount = $db->f("discount_amount");
                        $min_quantity = $db->f("min_quantity");
                        $max_quantity = $db->f("max_quantity");
                        $minimum_amount = $db->f("minimum_amount");
                        $maximum_amount = $db->f("maximum_amount");
                        $is_exclusive = $db->f("is_exclusive");
                        // check cart fields and total values
                        $min_cart_quantity = $db->f("min_cart_quantity");
                        $max_cart_quantity = $db->f("max_cart_quantity");
                        $min_cart_cost = $db->f("min_cart_cost");
                        $max_cart_cost = $db->f("max_cart_cost");
                        $cart_items_all = $db->f("cart_items_all");
                        $cart_items_ids = $db->f("cart_items_ids");
                        $cart_items_types_ids = $db->f("cart_items_types_ids");
                        check_cart_totals($cart_quantity, $cart_cost, $shopping_cart, $cart_items_all, $cart_items_ids, $cart_items_types_ids);
                        if ($quantity < $min_quantity || $basic_price < $minimum_amount || $max_quantity && $max_quantity < $quantity || $maximum_amount && $maximum_amount < $basic_price || $cart_quantity < $min_cart_quantity || $cart_cost < $min_cart_cost || $max_cart_quantity && $max_cart_quantity < $cart_quantity || $max_cart_cost && $max_cart_cost < $cart_cost) {
                            unset($shopping_cart[$cart_id]["COUPONS"][$coupon_id]);
                        } else {
                            // descrease product price for coupon discount
                            $discount_amount = $coupon_info["DISCOUNT_AMOUNT"];
                            $discounted_price -= $discount_amount;
                            $shopping_cart[$cart_id]["DISCOUNTED_PRICE"] = $discounted_price;
                            if ($is_exclusive) {
                                $exclusive_applied = true;
                            }
                            $coupons_total++;
                        }
                    } else {
                        unset($shopping_cart[$cart_id]["COUPONS"][$coupon_id]);
                    }
                }
            }
        }
    }
    // check if any order coupons should be removed
    // cart_quantity and cart_cost variable is used to check order coupons
    if (is_array($order_coupons)) {
        foreach ($order_coupons as $coupon_id => $coupon_info) {
            if ($auto_apply && $coupon_info["AUTO_APPLY"]) {
                // always remove auto-apply coupons
                unset($order_coupons[$coupon_id]);
            } else {
                $sql = " SELECT c.* FROM ";
                if (isset($site_id)) {
                    $sql .= "(";
                }
                $sql .= $table_prefix . "coupons c";
                if (isset($site_id)) {
                    $sql .= " LEFT JOIN  " . $table_prefix . "coupons_sites s ON s.coupon_id=c.coupon_id)";
                }
                $sql .= " WHERE c.coupon_id=" . $db->tosql($coupon_id, INTEGER);
                if (isset($site_id)) {
                    $sql .= " AND (c.sites_all=1 OR s.site_id=" . $db->tosql($site_id, INTEGER, true, false) . ")";
                } else {
                    $sql .= " AND c.sites_all=1 ";
                }
                $sql .= " ORDER BY c.apply_order ";
                $db->query($sql);
                if ($db->next_record()) {
                    $discount_type = $db->f("discount_type");
                    $coupon_discount = $db->f("discount_amount");
                    $is_exclusive = $db->f("is_exclusive");
                    // check cart fields and cart totals
                    $min_cart_quantity = $db->f("min_cart_quantity");
                    $max_cart_quantity = $db->f("max_cart_quantity");
                    $min_cart_cost = $db->f("min_cart_cost");
                    $max_cart_cost = $db->f("max_cart_cost");
                    check_cart_totals($cart_quantity, $cart_cost, $shopping_cart, 1, "", "");
                    if ($cart_quantity < $min_cart_quantity || $cart_cost < $min_cart_cost || $max_cart_quantity && $max_cart_quantity < $cart_quantity || $max_cart_cost && $max_cart_cost < $cart_cost) {
                        unset($order_coupons[$coupon_id]);
                    } else {
                        if ($is_exclusive) {
                            $exclusive_applied = true;
                        }
                        $coupons_total++;
                    }
                } else {
                    unset($order_coupons[$coupon_id]);
                }
            }
        }
    }
    // check if new coupons could be added
    $new_coupons = array();
    $coupon_title = "";
    if (strlen($new_coupon_code)) {
        $sql = " SELECT c.* FROM (" . $table_prefix . "coupons c";
        if (isset($site_id)) {
            $sql .= " LEFT JOIN  " . $table_prefix . "coupons_sites s ON s.coupon_id=c.coupon_id)";
        } else {
            $sql .= ")";
        }
        $sql .= " WHERE c.coupon_code=" . $db->tosql($new_coupon_code, TEXT);
        if (isset($site_id)) {
            $sql .= " AND (c.sites_all=1 OR s.site_id=" . $db->tosql($site_id, INTEGER, true, false) . ")";
        } else {
            $sql .= " AND c.sites_all=1 ";
        }
        $sql .= " ORDER BY c.apply_order ";
        $db->query($sql);
        if ($db->next_record()) {
            $new_coupon_id = $db->f("coupon_id");
            $start_date_db = $db->f("start_date", DATETIME);
            $expiry_date_db = $db->f("expiry_date", DATETIME);
            $coupon_title = $db->f("coupon_title");
            $new_coupons[$new_coupon_id] = $db->Record;
            $new_coupons[$new_coupon_id]["start_date_db"] = $start_date_db;
            $new_coupons[$new_coupon_id]["expiry_date_db"] = $expiry_date_db;
        }
    }
    $discount_types = array("3,4", "1,2", "5");
    // check products coupons, then order coupons and only then vouchers
    if ($auto_apply) {
        for ($dt = 0; $dt < sizeof($discount_types); $dt++) {
            $sql = " SELECT c.* FROM ";
            if (isset($site_id)) {
                $sql .= " ( ";
            }
            $sql .= $table_prefix . "coupons c";
            if (isset($site_id)) {
                $sql .= " LEFT JOIN  " . $table_prefix . "coupons_sites s ON s.coupon_id=c.coupon_id)";
            }
            $sql .= " WHERE c.is_auto_apply=1 ";
            $sql .= " AND c.discount_type IN (" . $discount_types[$dt] . ") ";
            if (isset($site_id)) {
                $sql .= " AND (c.sites_all=1 OR s.site_id=" . $db->tosql($site_id, INTEGER, true, false) . ")";
            } else {
                $sql .= " AND c.sites_all=1 ";
            }
            $sql .= " ORDER BY c.apply_order ";
            $db->query($sql);
            while ($db->next_record()) {
                $new_coupon_id = $db->f("coupon_id");
                $start_date_db = $db->f("start_date", DATETIME);
                $expiry_date_db = $db->f("expiry_date", DATETIME);
                $new_coupons[$new_coupon_id] = $db->Record;
                $new_coupons[$new_coupon_id]["start_date_db"] = $start_date_db;
                $new_coupons[$new_coupon_id]["expiry_date_db"] = $expiry_date_db;
            }
        }
    }
    // check if new coupons could be added
    if (sizeof($new_coupons) > 0) {
        foreach ($new_coupons as $new_coupon_id => $data) {
            $coupon_error = "";
            $is_active = $data["is_active"];
            $new_coupon_id = $data["coupon_id"];
            $coupon_auto_apply = $data["is_auto_apply"];
            $coupon_code = $data["coupon_code"];
            $coupon_title = $data["coupon_title"];
            $discount_type = $data["discount_type"];
            $discount_quantity = $data["discount_quantity"];
            $coupon_discount = $data["discount_amount"];
            $free_postage = $data["free_postage"];
            $coupon_tax_free = $data["coupon_tax_free"];
            $coupon_order_tax_free = $data["order_tax_free"];
            $items_all = $data["items_all"];
            $items_ids = $data["items_ids"];
            $items_types_ids = $data["items_types_ids"];
            $search_items_ids = explode(",", $items_ids);
            $search_items_types_ids = explode(",", $items_types_ids);
            $cart_items_all = $data["cart_items_all"];
            $cart_items_ids = $data["cart_items_ids"];
            $cart_items_types_ids = $data["cart_items_types_ids"];
            $users_all = $data["users_all"];
            $users_use_limit = $data["users_use_limit"];
            $users_ids = $data["users_ids"];
            $users_types_ids = $data["users_types_ids"];
            $search_users_ids = explode(",", $users_ids);
            $search_users_types_ids = explode(",", $users_types_ids);
            $expiry_date = "";
            $is_expired = false;
            $expiry_date_db = $data["expiry_date_db"];
            if (is_array($expiry_date_db)) {
                $expiry_date = va_date($date_show_format, $expiry_date_db);
                $expiry_date_ts = mktime(0, 0, 0, $expiry_date_db[MONTH], $expiry_date_db[DAY], $expiry_date_db[YEAR]);
                $current_date_ts = va_timestamp();
                if ($current_date_ts > $expiry_date_ts) {
                    $is_expired = true;
                }
            }
            $start_date = "";
            $is_upcoming = false;
            $start_date_db = $data["start_date_db"];
            if (is_array($start_date_db)) {
                $start_date = va_date($date_show_format, $start_date_db);
                $start_date_ts = mktime(0, 0, 0, $start_date_db[MONTH], $start_date_db[DAY], $start_date_db[YEAR]);
                $current_date_ts = va_timestamp();
                if ($current_date_ts < $start_date_ts) {
                    $is_upcoming = true;
                }
            }
            // check number how many times user can use coupon
            $user_not_limited = false;
            if ($users_use_limit && $user_id) {
                if ($discount_type == 3 || $discount_type == 4) {
                    $sql = " SELECT COUNT(*) FROM " . $table_prefix . "orders_items oi ";
                    $sql .= " WHERE oi.user_id=" . $db->tosql($user_id, INTEGER);
                    $sql .= " AND (oi.coupons_ids=" . $db->tosql($new_coupon_id, TEXT);
                    $sql .= " OR oi.coupons_ids LIKE '" . $db->tosql($new_coupon_id, INTEGER) . ",%'";
                    $sql .= " OR oi.coupons_ids LIKE '%," . $db->tosql($new_coupon_id, INTEGER) . "'";
                    $sql .= " OR oi.coupons_ids LIKE '%," . $db->tosql($new_coupon_id, INTEGER) . ",%') ";
                } else {
                    $sql = " SELECT COUNT(*) FROM (" . $table_prefix . "orders o ";
                    $sql .= " INNER JOIN " . $table_prefix . "orders_coupons oc ON o.order_id=oc.order_id) ";
                    $sql .= " WHERE o.user_id=" . $db->tosql($user_id, INTEGER);
                    $sql .= " AND oc.coupon_id=" . $db->tosql($new_coupon_id, INTEGER);
                }
                $user_uses = get_db_value($sql);
                if ($users_use_limit > $user_uses) {
                    $user_not_limited = true;
                }
            }
            // check goods cost limits
            $orders_period = $data["orders_period"];
            $orders_interval = $data["orders_interval"];
            $orders_min_goods = $data["orders_min_goods"];
            $orders_max_goods = $data["orders_max_goods"];
            $orders_goods_coupon = false;
            if ($user_id && ($orders_min_goods || $orders_max_goods)) {
                // check if user buy something in the past
                $sql = " SELECT SUM(o.goods_total) FROM (" . $table_prefix . "orders o ";
                $sql .= " INNER JOIN " . $table_prefix . "order_statuses os ON o.order_status=os.status_id) ";
                $sql .= " WHERE o.user_id=" . $db->tosql($user_id, INTEGER);
                $sql .= " AND os.paid_status=1 ";
                if ($orders_period && $orders_interval) {
                    $cd = va_time();
                    if ($orders_period == 1) {
                        $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY] - $orders_interval, $cd[YEAR]);
                    } elseif ($orders_period == 2) {
                        $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY] - $orders_interval * 7, $cd[YEAR]);
                    } elseif ($orders_period == 3) {
                        $od = mktime(0, 0, 0, $cd[MONTH] - $orders_interval, $cd[DAY], $cd[YEAR]);
                    } else {
                        $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY], $cd[YEAR] - $orders_interval);
                    }
                    $sql .= " AND order_placed_date>=" . $db->tosql($od, DATETIME);
                }
                $user_goods_cost = get_db_value($sql);
                if ($user_goods_cost >= $orders_min_goods && ($user_goods_cost <= $orders_max_goods || !strlen($orders_max_goods))) {
                    $orders_goods_coupon = true;
                }
            }
            // check for friends coupons
            $friends_coupon = false;
            $friends_discount_type = $data["friends_discount_type"];
            $friends_all = $data["friends_all"];
            $friends_ids = $data["friends_ids"];
            $friends_types_ids = $data["friends_types_ids"];
            $friends_period = $data["friends_period"];
            $friends_interval = $data["friends_interval"];
            $friends_min_goods = $data["friends_min_goods"];
            $friends_max_goods = $data["friends_max_goods"];
            $search_friends_ids = explode(",", $friends_ids);
            $search_friends_types_ids = explode(",", $friends_types_ids);
            if ($friends_discount_type == 1) {
                // check if user friends buy something
                $user_friends_goods = 0;
                if ($user_id) {
                    $sql = " SELECT SUM(o.goods_total) FROM (" . $table_prefix . "orders o ";
                    $sql .= " INNER JOIN " . $table_prefix . "order_statuses os ON o.order_status=os.status_id) ";
                    $sql .= " WHERE o.friend_user_id=" . $db->tosql($user_id, INTEGER);
                    $sql .= " AND os.paid_status=1 ";
                    if ($friends_period && $friends_interval) {
                        $cd = va_time();
                        if ($friends_period == 1) {
                            $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY] - $friends_interval, $cd[YEAR]);
                        } elseif ($friends_period == 2) {
                            $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY] - $friends_interval * 7, $cd[YEAR]);
                        } elseif ($friends_period == 3) {
                            $od = mktime(0, 0, 0, $cd[MONTH] - $friends_interval, $cd[DAY], $cd[YEAR]);
                        } else {
                            $od = mktime(0, 0, 0, $cd[MONTH], $cd[DAY], $cd[YEAR] - $friends_interval);
                        }
                        $sql .= " AND order_placed_date>=" . $db->tosql($od, DATETIME);
                    }
                    $user_friends_goods = get_db_value($sql);
                }
                if ($user_friends_goods >= $friends_min_goods && ($user_friends_goods <= $friends_max_goods || !strlen($friends_max_goods))) {
                    $friends_coupon = true;
                }
            } elseif ($friends_discount_type == 2) {
                $friend_code = get_session("session_friend");
                $friend_user_id = get_friend_info();
                $friend_type_id = get_session("session_friend_type_id");
                // check whose friends could use coupon
                if ($friends_all && $friend_user_id || $friend_user_id && in_array($friend_user_id, $search_friends_ids) || $friend_type_id && in_array($friend_type_id, $search_friends_types_ids)) {
                    $friends_coupon = true;
                }
            }
            // global options
            $is_exclusive = $data["is_exclusive"];
            $quantity_limit = $data["quantity_limit"];
            $coupon_uses = $data["coupon_uses"];
            // check cart total values
            $min_cart_quantity = $data["min_cart_quantity"];
            $max_cart_quantity = $data["max_cart_quantity"];
            $min_cart_cost = $data["min_cart_cost"];
            $max_cart_cost = $data["max_cart_cost"];
            if ($discount_type <= 2) {
                $cart_items_all = 1;
            }
            // for order coupons always use all cart products to calculate totals
            check_cart_totals($cart_quantity, $cart_cost, $shopping_cart, $cart_items_all, $cart_items_ids, $cart_items_types_ids);
            // product specific fields
            $min_quantity = $data["min_quantity"];
            $max_quantity = $data["max_quantity"];
            $minimum_amount = $data["minimum_amount"];
            $maximum_amount = $data["maximum_amount"];
            // check if coupon can be applied
            if (!$is_active) {
                $coupon_error = COUPON_NON_ACTIVE_MSG;
            } elseif ($quantity_limit > 0 && $coupon_uses >= $quantity_limit) {
                $coupon_error = COUPON_USED_MSG;
            } elseif ($is_expired) {
                $coupon_error = COUPON_EXPIRED_MSG;
            } elseif ($is_upcoming) {
                $coupon_error = COUPON_UPCOMING_MSG;
            } elseif (($exclusive_applied || $is_exclusive && $coupons_total > 0) && $discount_type != 5 && !is_only_gift_certificate()) {
                //Customization by Vital - allow gift cert. with other coupons
                $coupon_error = COUPON_EXCLUSIVE_MSG;
            } elseif ($discount_type <= 4 && $min_cart_cost > $cart_cost) {
                $coupon_error = str_replace("{cart_amount}", currency_format($min_cart_cost), MIN_CART_COST_ERROR);
            } elseif ($discount_type <= 4 && $max_cart_cost && $max_cart_cost < $cart_cost) {
                $coupon_error = str_replace("{cart_amount}", currency_format($max_cart_cost), MAX_CART_COST_ERROR);
            } elseif ($discount_type <= 4 && $min_cart_quantity > $cart_quantity) {
                $coupon_error = str_replace("{min_quantity}", $min_cart_quantity, COUPON_MIN_QTY_ERROR);
            } elseif ($discount_type <= 4 && $max_cart_quantity && $max_cart_quantity < $cart_quantity) {
                $coupon_error = str_replace("{max_quantity}", $max_cart_quantity, COUPON_MAX_QTY_ERROR);
            } elseif (!($users_all || $user_id && in_array($user_id, $search_users_ids) || $user_type_id && in_array($user_type_id, $search_users_types_ids))) {
                $coupon_error = COUPON_CANT_BE_USED_MSG;
                // coupon can't be used for current user
            } elseif ($users_use_limit && !$user_not_limited) {
                // coupon can't be used more times
                if ($users_use_limit == 1) {
                    $coupon_error = COUPON_CAN_BE_USED_ONCE_MSG;
                } else {
                    $coupon_error = str_replace("{use_limit}", $users_use_limit, COUPON_SAME_USE_LIMIT_MSG);
                }
            } elseif ($friends_discount_type > 0 && !$friends_coupon) {
                $coupon_error = COUPON_CANT_BE_USED_MSG;
                // coupon has friends options which can't be used for current user
            } elseif (($orders_min_goods || $orders_max_goods) && !$orders_goods_coupon) {
                $coupon_error = COUPON_CANT_BE_USED_MSG;
                // the sum of user purchased goods doesn't match with goods values for this coupon
            }
            // end coupons checks
            if (!$coupon_error) {
                // check products coupons
                $coupon_items = false;
                foreach ($shopping_cart as $cart_id => $item) {
                    $item_id = $item["ITEM_ID"];
                    $item_type_id = $item["ITEM_TYPE_ID"];
                    $properties_more = $item["PROPERTIES_MORE"];
                    //Customization by Vital
                    $properties_info_array = $item["PROPERTIES_INFO"];
                    $properties_info_array = reset($properties_info_array);
                    $coupon_size_applies = array();
                    if (preg_match('#\\((.*?)\\)#', $coupon_title, $sizes)) {
                        //get all sizes
                        $sizes[1] = strtolower(str_replace(" ", "", $sizes[1]));
                        //remove spaces and lowercase it
                        $coupon_size_applies = explode(",", $sizes[1]);
                        //place them in array
                    }
                    //place them in array
                    $size_does_not_apply = false;
                    $item_size = "";
                    if (count($coupon_size_applies) != 0 && strcasecmp($properties_info_array["NAME"], "size") == 0) {
                        $sql = "SELECT property_value FROM va_items_properties_values WHERE item_property_id=" . $properties_info_array["VALUES"][0];
                        $db->query($sql);
                        if ($db->next_record()) {
                            $item_size = strtolower($db->f("property_value"));
                        }
                        $size_does_not_apply = !in_array($item_size, $coupon_size_applies);
                    }
                    //Check if the coupon applies for the item size
                    if (strcasecmp($properties_info_array["NAME"], "size") == 0 && !$items_all) {
                        $sql = "SELECT COUNT(*) FROM va_coupons_sizes WHERE coupon_id=" . $new_coupon_id . " AND item_id=" . $item_id . " AND item_size_id=" . $properties_info_array["VALUES"][0];
                        $size_is_in = get_db_value($sql);
                        $sql = "SELECT COUNT(*) FROM va_coupons_sizes WHERE coupon_id=" . $new_coupon_id . " AND item_id=" . $item_id;
                        $other_sizes = get_db_value($sql);
                        $size_does_not_apply = $size_is_in == 0 && $other_sizes != 0 ? true : false;
                    }
                    //$coupon_error = $size_does_not_apply."  ".$coupon_size_applies;
                    //if (!$item_id || $properties_more > 0) { //original line
                    if (!$item_id || $properties_more > 0 || $size_does_not_apply) {
                        //EDN customization
                        // ignore the products which has options to be added first
                        continue;
                    }
                    $quantity = $item["QUANTITY"];
                    $basic_price = $item["BASIC_PRICE"];
                    $discounted_price = $item["DISCOUNTED_PRICE"];
                    // add a new coupon
                    if ($discount_type == 3 || $discount_type == 4) {
                        if ($basic_price >= $minimum_amount && $quantity >= $min_quantity && (!$maximum_amount || $basic_price <= $maximum_amount) && (!$max_quantity || $quantity <= $max_quantity) && ($items_all || in_array($item_id, $search_items_ids) || in_array($item_type_id, $search_items_types_ids))) {
                            // add coupon to products
                            $coupon_items = true;
                            if ($discount_type == 3) {
                                $discount_amount = round($basic_price / 100 * $coupon_discount, 2);
                            } else {
                                $discount_amount = $coupon_discount;
                            }
                            if ($discount_amount > $discounted_price) {
                                $discount_amount = $discounted_price;
                            }
                            $shopping_cart[$cart_id]["DISCOUNTED_PRICE"] -= $discount_amount;
                            if (!isset($shopping_cart[$cart_id]["COUPONS"][$new_coupon_id])) {
                                // calculate number of new applied coupons
                                $new_coupons_total++;
                            }
                            $shopping_cart[$cart_id]["COUPONS"][$new_coupon_id] = array("COUPON_ID" => $new_coupon_id, "EXCLUSIVE" => $is_exclusive, "DISCOUNT_QUANTITY" => $discount_quantity, "DISCOUNT_AMOUNT" => $discount_amount, "AUTO_APPLY" => $coupon_auto_apply);
                            if ($is_exclusive) {
                                $exclusive_applied = true;
                            }
                            $coupons_total++;
                        }
                    }
                }
                if (($discount_type == 3 || $discount_type == 4) && !$coupon_items) {
                    $coupon_error = COUPON_PRODUCTS_MSG;
                }
                // end products checks
                // check order coupons
                if ($discount_type <= 2 || $discount_type == 5) {
                    if (!isset($order_coupons[$new_coupon_id])) {
                        $new_coupons_total++;
                    }
                    // add new coupon to system
                    $order_coupons[$new_coupon_id] = array("COUPON_ID" => $new_coupon_id, "DISCOUNT_TYPE" => $discount_type, "EXCLUSIVE" => $is_exclusive, "COUPON_TAX_FREE" => $coupon_tax_free, "MIN_QUANTITY" => $min_cart_quantity, "MAX_QUANTITY" => $max_cart_quantity, "MIN_AMOUNT" => $min_cart_cost, "MAX_AMOUNT" => $max_cart_cost, "ORDER_TAX_FREE" => $coupon_order_tax_free, "AUTO_APPLY" => $coupon_auto_apply);
                    if ($is_exclusive) {
                        $exclusive_applied = true;
                    }
                    $coupons_total++;
                }
                // end order coupons checks
            }
            if (strtolower($coupon_code) == strtolower($new_coupon_code) && $coupon_error) {
                $new_coupon_error = $coupon_error;
            }
        }
    }
    // end check a new coupons and auto-applied coupons
    // update shopping cart and order coupons
    set_session("shopping_cart", $shopping_cart);
    set_session("session_coupons", $order_coupons);
    // return number of applied coupons
    return $new_coupons_total;
}
Example #27
0
function print_company_autocomplete_input($parameters)
{
    if (isset($parameters['input_name'])) {
        $input_name = $parameters['input_name'];
    }
    $input_value = '';
    $company_name = '';
    if (isset($parameters['input_value'])) {
        $input_value = $parameters['input_value'];
        $company_name = get_db_value("name", "tcompany", "id", $input_value);
        if (!$company_name) {
            $company_name = "";
        }
    }
    if (isset($parameters['input_id'])) {
        $input_id = $parameters['input_id'];
    }
    $return = false;
    if (isset($parameters['return'])) {
        $return = $parameters['return'];
    }
    //$input_size = 15;
    if (isset($parameters['size'])) {
        $input_size = $parameters['size'];
    }
    //$input_maxlength = 50;
    if (isset($parameters['maxlength'])) {
        $input_maxlength = $parameters['maxlength'];
    }
    $title = '';
    if (isset($parameters['title'])) {
        $title = $parameters['title'];
    }
    $help_message = "Type at least two characters to search";
    if (isset($parameters['help_message'])) {
        $help_message = $parameters['help_message'];
    }
    $return_help = true;
    if (isset($parameters['return_help'])) {
        $return_help = $parameters['return_help'];
    }
    $filter = "";
    if (isset($parameters['filter'])) {
        $filter = $parameters['filter'];
    }
    $attributes = 'class="company_autocomplete"';
    $html = "";
    $html .= print_input_text_extended("autocomplete_" . $input_name, $company_name, $input_id, '', $input_size, $input_maxlength, false, '', $attributes, true, '', __($title)) . print_help_tip(__($help_message), $return_help);
    $html .= print_input_hidden($input_name, $input_value, true);
    if ($filter) {
        $html .= print_input_hidden("autocomplete_" . $input_name . "_filter", $filter, true);
    }
    if ($return) {
        return $html;
    } else {
        echo $html;
    }
}
                $top_category_id = $category_id;
            } else {
                $art_category_path_parts = explode(",", $art_category_path);
                if (isset($art_category_path_parts[1])) {
                    $top_category_id = $art_category_path_parts[1];
                } else {
                    $top_category_id = $category_id;
                }
            }
        } else {
            $top_category_id = "0";
        }
    } else {
        $product_page = "articles.php";
        $sql = "SELECT category_path FROM " . $table_prefix . "articles_categories WHERE category_id=" . $db->tosql($category_id, INTEGER);
        $art_category_path = get_db_value($sql);
        if ("0," == $art_category_path) {
            $top_category_id = $category_id;
        } else {
            $art_category_path_parts = explode(",", $art_category_path);
            if (isset($art_category_path_parts[1])) {
                $top_category_id = $art_category_path_parts[1];
            } else {
                $top_category_id = $category_id;
            }
        }
    }
    // TODO: check if block_key could be used for $top_category_id
    $records_per_page = get_setting_value($vars, "articles_products_cats_recs", 5);
    $related_columns_param = "articles_products_cats_cols";
} else {
Example #29
0
        $table->size = array();
        $table->size[3] = '40px';
        $table->style = array();
        // $table->style[] = 'font-weight: bold';
        $table->head = array();
        $table->head[0] = __('Full name');
        $table->head[1] = __('Company');
        $table->head[2] = __('Email');
        if ($section_write_permission || $section_manage_permission) {
            $table->head[3] = __('Delete');
        }
        foreach ($contacts as $contact) {
            $data = array();
            // Name
            $data[0] = "<a href='index.php?sec=customers&sec2=operation/contacts/contact_detail&id=" . $contact['id'] . "'>" . $contact['fullname'] . "</a>";
            $data[1] = "<a href='index.php?sec=customers&sec2=operation/companies/company_detail&id=" . $contact['id_company'] . "'>" . get_db_value('name', 'tcompany', 'id', $contact['id_company']) . "</a>";
            $data[2] = $contact['email'];
            if ($section_write_permission || $section_manage_permission) {
                $data[3] = '<a href="index.php?sec=customers&
							sec2=operation/contacts/contact_detail&
							delete_contact=1&id=' . $contact['id'] . '&offset=' . $offset . '"
							onClick="if (!confirm(\'' . __('Are you sure?') . '\'))
							return false;">
							<img src="images/cross.png"></a>';
            }
            array_push($table->data, $data);
        }
        print_table($table);
    }
    //Show create button only when contact list is displayed
    if (($section_write_permission || $section_manage_permission) && !$id && !$new_contact) {
Example #30
0
 private function showWorkOrder($message = "")
 {
     $system = System::getInstance();
     $ui = Ui::getInstance();
     $ui->createPage();
     $back_href = "index.php?page=workorders&filter_status=0&filter_owner=" . $system->getConfig('id_user');
     if ($this->id_workorder < 0) {
         $title = __("Workorder");
     } else {
         $title = __("Workorder") . "&nbsp;#" . $this->id_workorder;
     }
     $ui->createDefaultHeader($title, $ui->createHeaderButton(array('icon' => 'back', 'pos' => 'left', 'text' => __('Back'), 'href' => $back_href)));
     $ui->beginContent();
     // Message popup
     if ($message != "") {
         $options = array('popup_id' => 'message_popup', 'popup_content' => $message);
         $ui->addPopup($options);
         $ui->contentAddHtml("<script type=\"text/javascript\">\n\t\t\t\t\t\t\t\t\t\t\$(document).on('pageshow', function() {\n\t\t\t\t\t\t\t\t\t\t\t\$(\"#message_popup\").popup(\"open\");\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script>");
     }
     $options = array('id' => 'form-workorder', 'action' => "index.php?page=workorder", 'method' => 'POST');
     $ui->beginForm($options);
     // Title
     $options = array('name' => 'title', 'label' => __('Title'), 'value' => $this->title, 'placeholder' => __('Title'));
     $ui->formAddInputText($options);
     // Assigned user
     $options = array('name' => 'assigned_user', 'id' => 'text-assigned_user', 'label' => __('Assigned user'), 'value' => $this->assigned_user, 'placeholder' => __('Assigned user'), 'autocomplete' => 'off');
     $ui->formAddInputText($options);
     // Assigned user autocompletion
     // List
     $ui->formAddHtml("<ul id=\"ul-autocomplete\" data-role=\"listview\" data-inset=\"true\"></ul>");
     // Autocomplete binding
     $ui->bindMobileAutocomplete("#text-assigned_user", "#ul-autocomplete");
     // Status
     $values = array();
     if (get_db_value("need_external_validation", "ttodo", "id", $this->id_workorder)) {
         $values = wo_status_array(0);
     } else {
         $values = wo_status_array(1);
     }
     $options = array('name' => 'status', 'title' => __('Status'), 'label' => __('Status'), 'items' => $values, 'selected' => $this->status);
     $ui->formAddSelectBox($options);
     // Priority
     $values = array();
     $values = get_priorities();
     $options = array('name' => 'priority', 'title' => __('Priority'), 'label' => __('Priority'), 'items' => $values, 'selected' => $this->priority);
     $ui->formAddSelectBox($options);
     // Category
     $workorders = get_db_all_rows_sql("SELECT id, name FROM two_category ORDER BY name");
     $values = array();
     if ($workorders) {
         foreach ($workorders as $workorder) {
             $values[$workorder[0]] = $workorder[1];
         }
     }
     array_unshift($values, __('Any'));
     $options = array('name' => 'category', 'title' => __('Category'), 'label' => __('Category'), 'items' => $values, 'selected' => $this->category);
     $ui->formAddSelectBox($options);
     // Task
     $sql = "SELECT ttask.id, tproject.name, ttask.name\n\t\t\t\t\t\tFROM ttask, trole_people_task, tproject\n\t\t\t\t\t\tWHERE ttask.id_project = tproject.id\n\t\t\t\t\t\t\tAND tproject.disabled = 0\n\t\t\t\t\t\t\tAND ttask.id = trole_people_task.id_task\n\t\t\t\t\t\t\tAND trole_people_task.id_user = '******'id_user') . "'\n\t\t\t\t\t\tORDER BY tproject.name, ttask.name";
     if (dame_admin($system->getConfig('id_user'))) {
         $sql = "SELECT ttask.id, tproject.name, ttask.name \n\t\t\t\t\t\t\tFROM ttask, tproject\n\t\t\t\t\t\t\tWHERE ttask.id_project = tproject.id\n\t\t\t\t\t\t\t\tAND tproject.disabled = 0\n\t\t\t\t\t\t\tORDER BY tproject.name, ttask.name";
     }
     $tasks = get_db_all_rows_sql($sql);
     $values = array();
     $values[0] = __('N/A');
     if ($tasks) {
         foreach ($tasks as $task) {
             $values[$task[0]] = array('optgroup' => $task[1], 'name' => $task[2]);
         }
     }
     $selected = $this->id_task > 0 ? $this->id_task : 0;
     $options = array('name' => 'id_task', 'title' => __('Task'), 'label' => __('Task'), 'items' => $values, 'selected' => $selected);
     $ui->formAddSelectBox($options);
     // Description
     $options = array('name' => 'description', 'label' => __('Description'), 'value' => $this->description);
     $ui->formAddHtml($ui->getTextarea($options));
     // Hidden operation (insert or update+id)
     if ($this->id_workorder < 0) {
         $options = array('type' => 'hidden', 'name' => 'operation', 'value' => 'insert');
         $ui->formAddInput($options);
         // Submit button
         $options = array('text' => __('Add'), 'data-icon' => 'plus');
         $ui->formAddSubmitButton($options);
     } else {
         $options = array('type' => 'hidden', 'name' => 'operation', 'value' => 'update');
         $ui->formAddInput($options);
         $options = array('type' => 'hidden', 'name' => 'id_workorder', 'value' => $this->id_workorder);
         $ui->formAddInput($options);
         // Submit button
         $options = array('text' => __('Update'), 'data-icon' => 'refresh');
         $ui->formAddSubmitButton($options);
     }
     $ui->endForm();
     $ui->endContent();
     // Foooter buttons
     // Add
     if ($this->id_workorder < 0) {
         $button_add = "<a onClick=\"\$('#form-workorder').submit();\" data-role='button' data-icon='plus'>" . __('Add') . "</a>\n";
     } else {
         $button_add = "<a onClick=\"\$('#form-workorder').submit();\" data-role='button' data-icon='refresh'>" . __('Update') . "</a>\n";
     }
     // Delete
     $workorder_creator = get_db_value("created_by_user", "ttodo", "id", $this->id_workorder);
     if ($this->id_workorder > 0 && (dame_admin($system->getConfig('id_user')) || $system->getConfig('id_user') == $workorder_creator)) {
         $button_delete = "<a href='index.php?page=workorders&operation=delete&id_workorder=" . $this->id_workorder . "\n\t\t\t\t\t\t\t\t\t&filter_status=0&filter_owner=" . $system->getConfig('id_user') . "' data-ajax='false'\n\t\t\t\t\t\t\t\t\tdata-role='button' data-icon='delete'>" . __('Delete') . "</a>\n";
     }
     $ui->createFooter("<div data-type='horizontal' data-role='controlgroup'>{$button_add}" . "{$button_delete}</div>");
     $ui->showFooter();
     $ui->showPage();
 }