Esempio n. 1
0
function search_array($needle, $haystack)
{
    if (in_array($needle, $haystack)) {
        return true;
    }
    foreach ($haystack as $element) {
        if (is_array($element) && search_array($needle, $element)) {
            return true;
        }
    }
    return false;
}
function process_json($ResponseObject, $categoryArray)
{
    if ($ResponseObject->response->record_count == '') {
        echo "<strong>Error</strong><br>";
        echo ".....................................................................<br>";
        echo "No products detected <br>";
        echo "Query Value: " . $categoryArray['queryValue'] . "<br>";
        echo "Parent Category: " . $categoryArray['parentCategory'] . "<br>";
        echo "Sub Category: " . $categoryArray['subCategory'] . "<br>";
        echo ".....................................................................<br><br>";
    } else {
        // Loot through products
        foreach ($ResponseObject->response->records as $Item) {
            $searchValue = $Item->itemcode;
            $product_checker_return = search_array($searchValue);
            if (is_null($product_checker_return)) {
                write_to_array($Item, $categoryArray);
            } else {
                // echo "Match Found:". $product_checker_return . "<br>";
                append_array($product_checker_return, $categoryArray);
            }
        }
    }
}
 function check_field_property($field_name, $property)
 {
     $fields = $this->get_tickets_instances_fields();
     $result = search_array($fields, 'field_name', $field_name);
     return $result[0]['post_field_type'];
 }
 function check_field_property($field_name, $property)
 {
     $fields = $this->get_discount_fields();
     $result = search_array($fields, 'field_name', $field_name);
     return isset($result[0]['post_field_type']) ? $result[0]['post_field_type'] : '';
 }
Esempio n. 5
0
        return $minutes . ' minutes ago';
    }
}
$noti = $db->getRecord(NOTI, '', " `by` = 'associate' AND `status` = 'unread' order by id DESC  limit 5");
$users = $db->getRecord(USERS);
?>
<ul class="notitab">
	<li class="current"><a href="#messages">Activities</a></li>
</ul>

<div id="messages">
    <ul class="msglist">
<?php 
if ($noti) {
    foreach ($noti as $key => $value) {
        $usrId = search_array($value['userId'], 'userId', $users);
        $us = $users[$usrId][companyName];
        if ($value['type'] == 'service') {
            $cnt = count(explode(',', $value['remark']));
            $img = 'service.png';
            $page = 'associate-view.php?userId=' . $value['userId'] . '&address=' . $value['typeId'] . '&notiId=' . $value['id'];
            $msg = $value['remark'] . ' ' . ucwords($us);
        } else {
            if ($value['type'] == 'address') {
                $username = $users[$userId]['companyName'];
                $img = 'address.png';
                $page = 'associate-view.php?userId=' . $value['userId'] . '&address=' . $value['typeId'] . '&notiId=' . $value['id'];
                $msg = $value['remark'] . ' ' . ucwords($us);
            }
        }
        ?>
Esempio n. 6
0
    $tmp = '';
    for ($i = 0; $i < count($srv); $i++) {
        $id = search_array($srv[$i], 'id', $service);
        $tmp .= ucwords($service[$id]['name']) . ', ';
    }
    echo trim($tmp, ', ');
    ?>
</th>
             	
				<?php 
    if ($noti[0]['record'] != 'new') {
        ?>
<th class="head0"><?php 
        $tmp = '';
        for ($i = 0; $i < count($srv); $i++) {
            $id = search_array($srv[$i], 'id', $service);
            $tmp .= ucwords($service[$id]['name']) . ', ';
        }
        echo trim($tmp, ', ');
        ?>
</th><?php 
    }
    ?>
        	</tr> 
<?php 
}
?>
        </thead>
       </tbody>
    </table>  
<br />
Esempio n. 7
0
 public function getDistribution($stat1, $stat2, $factor)
 {
     if (!$this->isValidStat($stat1) || !$this->isValidStat($stat2) || !is_numeric($factor)) {
         return new \stdClass();
     } else {
         $stmt = $this->db()->prepare("CALL GetDistributionForRatio(?, ?, ?);");
         $stmt->execute(array($stat1, $stat2, $factor));
         $stmt = $this->db()->query("SELECT * FROM DistributionForRatio;");
         $dist = new \stdClass();
         $dist->stat = array("stat1" => $stat1, "stat2" => $stat2, "factor" => $factor);
         while ($row = $stmt->fetch()) {
             extract($row);
             $dist->distribution->steps[] = $step;
             $dist->distribution->count[] = $count;
         }
         $start = 0;
         // - $factor;
         $steps = array();
         $counts = array();
         $breaks = array();
         // If dealing with a factor >= 1, always use ints.
         if ($factor >= 1) {
             for ($i = 0; $i < sizeof($dist->distribution->steps); $i++) {
                 $dist->distribution->steps[$i] = intval($dist->distribution->steps[$i]);
             }
         }
         if ($dist->distribution->steps[0] !== 0 && floatval($dist->distribution->steps[0]) !== floatval(0)) {
             array_unshift($dist->distribution->steps, 0);
             array_unshift($dist->distribution->count, 0);
         }
         // Add 1 step to the end
         $last = $dist->distribution->steps[count($dist->distribution->steps) - 1];
         array_push($dist->distribution->steps, $last + $factor);
         array_push($dist->distribution->count, 0);
         // Make sure "steps" (each increament of factor) is sequential. If there are more than $THRESHOLD
         // increments with no value, save it as a "break" in continuity
         $THRESHOLD = 5;
         foreach ($dist->distribution->steps as $step) {
             if ($step - $factor > $start) {
                 if ($step - $start > $factor * $THRESHOLD) {
                     $breaks[] = array($start, $step);
                     array_push($steps, $step);
                     $start = $step + $factor * $THRESHOLD;
                 } else {
                     foreach (range($start + $factor, $step, $factor) as $n) {
                         array_push($steps, $n);
                         $start = $n;
                     }
                 }
             } else {
                 array_push($steps, $step);
                 $start = $step;
             }
         }
         // custom array_search function for precision
         function search_array($value, &$array)
         {
             for ($i = 0; $i < sizeof($array); $i++) {
                 if (bccomp(floatval($value), floatval($array[$i]), 1) === 0) {
                     return $i;
                 }
             }
             return false;
         }
         // insert 0 for steps that where previously created
         foreach ($steps as $step) {
             $step = floatval($step);
             $i = search_array($step, $dist->distribution->steps);
             if ($i !== false) {
                 $value = $dist->distribution->count[$i];
                 array_push($counts, $value);
             } else {
                 array_push($counts, 0);
             }
         }
         $dist->distribution->breaks = $breaks;
         $dist->distribution->steps = $steps;
         $dist->distribution->count = $counts;
         return $dist;
     }
 }
Esempio n. 8
0
    echo " {$rus_week_array[$nextDayOfWeek]}";
    ?>
,  <?php 
    echo "{$startDate} {$month_name_rus}";
    ?>
</p>
		<form>
		<?php 
    $z = 0;
    foreach ($times as $temp) {
        echo '<div>
					<a href="#modal_form" id="go" class="button-reserv ';
        if ($nowDay == $startDate && $nowTime >= $temp && $nowTime <= 958) {
            //закрываем забронированные ячейки в зависимости от текущего времени
            echo $FalseTime;
        } elseif ($CheckDate == search_array($GetTimeReg, $temp)) {
            //перебираем массив по времени бронирования
            if (search_array2($GetTimeReg, $temp) == 1) {
                //если бронь есть проверяем подверждено или нет
                echo $FalseTime;
            } else {
                echo $waitReg;
            }
        } elseif ($temp == 802 || $temp == 854) {
            //на вечернее время ставим зеленые кнопки
            echo $CrazyTime;
        } elseif ($nextDayOfWeek >= 1 && $nextDayOfWeek <= 5) {
            //выбираем будни
            if ($temp == 750 || $temp == 698 || $temp == 645) {
                //время в буднях красим синим или оранжевым
                echo $TrueTime;
Esempio n. 9
0
function IsAllowed($name)
{
    global $level;
    if ($level == 2) {
        return 2;
    }
    if ($users[0] == "") {
        return 2;
    }
    /* empty users array means everyone is allowed to access */
    if ($name == 'admin') {
        return 2;
    }
    if (!strcmp("{$name}\n", $users[0])) {
        return 2;
    }
    if (search_array("{$name}\n", $users)) {
        return 1;
    }
    return 0;
}
        function check_field_property($field_name, $property)
        {
            $fields = $this->get_template_col_fields();
            $result = search_array($fields, 'field_name', $field_name);
            return $result[0]['post_field_type

                 '];
        }
                     array_push($data, $item);
                     array_push($elements_checked, $data_value['dataElement']);
                 }
             }
         }
     } else {
         //Do Nothing
     }
     $org_units_data = array_merge($org_units_data, $data);
 }
 $elements_checked = array();
 $data = array();
 foreach ($org_units_data as $data_value) {
     if (isset($data_value['dataElement'])) {
         if (!is_item_in_array($elements_checked, $data_value['dataElement'])) {
             $dataElements = search_array($org_units_data, $data_value['dataElement']);
             $consumption_val = 0;
             $resupply_quantity_val = 0;
             $stock_at_hand_val = 0;
             $months_stock = 0;
             //            var_dump($dataElements);
             foreach ($dataElements as $dataElement) {
                 if (isset($dataElement["consumption"])) {
                     $consumption_val = $consumption_val + intval($dataElement["consumption"]);
                 }
                 if (isset($dataElement["stock_at_hand"])) {
                     $stock_at_hand_val = $stock_at_hand_val + intval($dataElement["stock_at_hand"]);
                 }
                 if (isset($dataElement["resupply_quantity"])) {
                     $resupply_quantity_val = $resupply_quantity_val + intval($dataElement["resupply_quantity"]);
                 }
Esempio n. 12
0
<?php 
isset($_GET['isi2']) && $adadata && search_array($_GET['isi2'], $adadata) ? $prm = '?eb' : ($prm = '');
?>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
    <input type="hidden" id="aksi" value="<?php 
echo isset($lastid) ? $lastid : '';
?>
" />
    <input type="hidden" id="mng" value="<?php 
echo isset($idslug) ? $idslug . $prm : '';
?>
" />
			<table class="table table-bordered">
      <thead>
      <tr>
        <td>No</td>
        <td>Description of Goods</td>
        <td>Qty</td>
        <td>Disc</td>
        <td>Price</td>
        <td>Subtotal</td>
        <td>Action</td>
      </tr>
      </thead>
      <tbody>      
     <tr id="addrow">
        <td>0</td>
        <td><?php 
Esempio n. 13
0
                        </tr>
                    </tfoot>
                    <tbody>
<?php 
$service = $db->getRecord(SERVICE);
$state = $db->getRecord(REGION);
$city = $db->getRecord(CITY);
$qry = $db->runQuery("select * from " . ADDRESS . " where userId = '" . $_REQUEST['userId'] . "'  order by id DESC ");
if (@mysqli_num_rows($qry) > 0) {
    while ($view = $db->getQuery($qry)) {
        $cityId = search_array($view['city'], 'pk_i_id', $city);
        $stateId = search_array($view['state'], 'pk_i_id', $state);
        $tmp = '';
        $srv = explode(',', $view['service']);
        for ($i = 0; $i < count($srv); $i++) {
            $tmp .= ucwords($service[search_array($srv[$i], 'id', $service)]['name']) . ', ';
        }
        ?>
     <tr>
            <td class="con0"><?php 
        echo ucwords($view['name']);
        ?>
</td>
			<td class="con0"><?php 
        echo $view['email'];
        ?>
</td>
         	<td class="con0"><?php 
        echo $view['mobileNo'];
        ?>
</td>
Esempio n. 14
0
#!/usr/local/bin/php
<?php 
$my_array = file("/tmp/cached/movieName.dat");
$search_term = $_GET['term'];
function search_array(array $array, $term)
{
    foreach ($array as $key => $value) {
        if (stripos($value, $term) !== false) {
            return $key;
        }
    }
    return false;
}
print search_array($my_array, $search_term);
Esempio n. 15
0
<?php

header('Content-Type: application/json');
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/init.inc.php';
if (isset($_GET['term'])) {
    $users = search_array('nsh_users', 'name', $_GET['term']);
    $usernames = array_column($users, 'name');
    $response = json_encode($usernames);
    echo $response;
}
function search_array($array, $key, $value)
{
    $results = array();
    if (is_array($array)) {
        if (isset($array[$key]) && $array[$key] == $value) {
            $results[] = $array;
        }
        foreach ($array as $subarray) {
            $results = array_merge($results, search_array($subarray, $key, $value));
        }
    }
    return $results;
}