Beispiel #1
0
    if ($where != '') {
        $where .= " and ";
    } else {
        $where = " where";
    }
    if ($date_from != '' && $date_to != '') {
        $where .= " date_sent >= '" . date("Y-m-d", strtotime($date_from)) . " 00:00:00' and date_sent <='" . date("Y-m-d", strtotime($date_to)) . " 23:59:59'";
    } else {
        if ($date_from != '') {
            $where .= " date_sent like '" . date("Y-m-d", strtotime($date_from)) . "%' ";
        } else {
            $where .= " date_sent like '" . date("Y-m-d", strtotime($date_to)) . "%' ";
        }
    }
}
$select = "select " . toStringList($select_list) . $sel . " from sms_files as a left join po_file as k on a.trans_no=k.trans_no  {$where} ";
//    echo $select;
?>
    <h2><?php 
echo $title;
?>
</h2>
    <form name='form1' id='form1' method=post>
    <table class='table_data'>
    <?php 
$result = $conn->query($select . " order by {$order} limit {$start},{$limit}");
// echo $select." order by $order limit $start,$limit";
$table = "";
$table .= "<tr>";
$table .= "<th>Sender</th>";
for ($a = 0; $a < count($select_list); $a++) {
Beispiel #2
0
function listMaker($table_name, $order, $select_list, $title)
{
    global $conn;
    global $access;
    //print_r($access);
    $sel = " ";
    if ($order == 'secretary' || $order == 'engineer') {
        $sel = " ,account_executive_id";
    }
    //   echo "<br>".$table_name."<br>";
    if ($table_name == 'master_address_file') {
        $this_id = "account_id";
        $sel .= ",account_id";
    } else {
        if ($table_name == 'user_file') {
            $this_id = "user_id";
            $sel .= ",user_id";
        } else {
            if ($table_name == 'sms_files as a left join po_file as k on a.trans_no=k.trans_no') {
                $this_id = "sms_id";
                $sel .= ",sms_id";
            } else {
                $sel .= ",id";
                $this_id = "id";
            }
        }
    }
    $select = "select " . toStringList($select_list) . $sel . "  from {$table_name} order by {$order}";
    // echo $select;
    ?>
    <h2><?php 
    echo $title;
    ?>
</h2>
    <form name='form1' id='form1' method=post>
    <table class='table_data'>
    <?php 
    $result = $conn->query($select);
    echo "<tr>";
    for ($a = 0; $a < count($select_list); $a++) {
        if ($select_list[$a] == 'department_id') {
            echo "<th>Department</th>";
        } else {
            if ($select_list[$a] == 'account_executive_id') {
                echo "<th>Account Executive</th>";
            } else {
                echo "<th>" . ucwords(str_replace("_", " ", $select_list[$a])) . "</tk>";
            }
        }
    }
    if ($order == 'secretary' || $order == 'engineer') {
        echo "<th>Account Executive</tk>";
    }
    echo "<th colspan=2 style='text-align:left'>Action</th>";
    echo "</tr>";
    $executive = array();
    $department_list = array();
    while ($row = $result->fetch_assoc()) {
        /*
                if(($order=='secretary'|| $order=='engineer') && empty($executive[$row['account_executive_id']]))
                {
                    $select="select account_executive from master_account_executive_file where account_executive_id='".$row['account_executive_id']."' limit 1";
                    $result2= $conn->query($select);
                    $row2=$result2->fetch_assoc();
                    $executive[$row['account_executive_id']]=$row2['account_executive'];
                }*/
        echo "<tr>";
        for ($a = 0; $a < count($select_list); $a++) {
            if ($select_list[$a] == 'account_type') {
                echo "<td>" . ucwords(str_replace("_", " ", $row['account_type'])) . "</td>";
            } else {
                if ($select_list[$a] == 'mas_status') {
                    if ($row['mas_status'] == 1) {
                        echo "<td>Active</td>";
                    } else {
                        echo "<td>Inactive</td>";
                    }
                } else {
                    if ($select_list[$a] == 'department_id') {
                        if (empty($department_list[$row[$select_list[$a]]])) {
                            $select = "select department from master_department_file where department_id='" . $row[$select_list[$a]] . "' limit 1";
                            $result2 = $conn->query($select);
                            $row2 = $result2->fetch_assoc();
                            $department_list[$row[$select_list[$a]]] = $row2['department'];
                        }
                        echo "<td>" . $department_list[$row[$select_list[$a]]] . "</td>";
                    } else {
                        if ($select_list[$a] == 'account_executive_id') {
                            if (empty($accout_exe[$row[$select_list[$a]]])) {
                                $select = "select concat(first_name,' ',last_name) as name from master_address_file where account_type='account_executive' and account_id='" . $row[$select_list[$a]] . "' limit 1";
                                $result2 = $conn->query($select);
                                $row2 = $result2->fetch_assoc();
                                $accout_exe[$row[$select_list[$a]]] = $row2['name'];
                            }
                            echo "<td>" . $accout_exe[$row[$select_list[$a]]] . "</td>";
                        } else {
                            if ($select_list[$a] == 'date_created') {
                                echo "<td>" . date("F j, Y") . "</td>";
                            } else {
                                echo "<td>" . $row[$select_list[$a]] . "</td>";
                            }
                        }
                    }
                }
            }
        }
        if ($order == 'secretary' || $order == 'engineer') {
            echo "<td>" . $executive[$row['account_executive_id']] . "</td>";
        }
        echo "<td>";
        if (!empty($access['Edit'])) {
            if ($table_name != 'sms_files as a left join po_file as k on a.trans_no=k.trans_no') {
                echo "<td><img  src='assets/Edit.png' name='image' width='20' height='20'  onclick='edit_list(" . $row[$this_id] . ")'></td>";
            }
        }
        if (!empty($access['Deactivate'])) {
            if ($row['mas_status'] == 0) {
                echo "<td><img  src='assets/check.png' name='image' width='20' height='20' onclick='check_list(" . $row[$this_id] . ")'></td>";
            } else {
                echo "<td><img  src='assets/cross.jpg' name='image' width='21' height='20' onclick='deactivate(" . $row[$this_id] . ")'></td>";
            }
        }
        echo "</tr>";
    }
    ?>
  
    </table>
    </form>
    <?php 
}