Exemple #1
0
 public function testAction()
 {
     d(convertUKtoUSdate('03/05/2014'));
     d(convertUStoUKdate('2014-05-03'));
 }
Exemple #2
0
 /**
  * Render CRUD Table
  * 
  * @param mixed $table
  * @param mixed $s_text
  * @param mixed $icon_class
  * @param mixed $del_in_value
  * @param mixed $array_in
  * @param mixed $array_nv
  */
 public static function renderCrudTable($thisss, $table = '', $s_text = '', $icon_class = '', $del_in_value = '', $array_in = array(), $array_nv = array(), $other_status = false, $extra_text = '', $show_add = true, $show_edit = true, $show_delete = true, $inFront = false, $extra_html = '', $extra_columns = array(), $withApproveReject = false)
 {
     include APPLICATION_PATH . '/views/helpers/ShowStatusChange.php';
     $sscHelper = new Zend_View_Helper_ShowStatusChange();
     $_table = $s_text == 'order' || $s_text == 'buyback' ? $table . '?type=' . $s_text : $table;
     $_title = $s_text == 'order' || $s_text == 'buyback' ? $s_text : $table;
     $out = '<header>';
     if ($show_add) {
         $out .= '<a href="#" class="btn btn-primary pull-right ajax-add-item" data-table="' . $_table . '" data-title="' . $_title . '">
                                                                 <span class="glyphicon glyphicon-plus"></span> Add ' . ucfirst($s_text) . '</a>';
     }
     $out .= '<h2><span class="' . $icon_class . '"></span> ' . (!empty($extra_text) ? $extra_text : ucfirst($table)) . '</h2>';
     $out .= !empty($extra_html) ? $extra_html : '';
     $out .= '<hr />
         </header>';
     if (!empty($array_in)) {
         if ($withApproveReject) {
             $out .= '<form enctype="multipart/form-data" method="post" action="' . $thisss->baseUrl('approve-reject-ob') . '" class="pullLeft" id="arObForm">
                             <div class="pull-left">
                                  <button type="submit" name="' . $s_text . '_approved" class="btn btn-primary mr10">
                                                 <span class="glyphicon glyphicon-ok"></span> Approve selected</button>
                                  <button type="submit" name="' . $s_text . '_rejected" class="btn btn-primary mr10 reject-selected">
                                                             <span class="glyphicon glyphicon-remove"></span> Reject selected</button>
                                  <a href="#" class="btn btn-primary mr10 check-all">Check all</a>
                                  <a href="#" class="btn btn-primary mr10 uncheck-all">Uncheck all</a>
                             </div>
                             <div class="clearfix">&nbsp;</div>
                           ';
         }
         $out .= '
                 <table class="table table-striped">
                      <thead>';
         if ($inFront) {
             if (!empty($extra_columns)) {
                 foreach ($extra_columns as $column) {
                     $out .= '<th>' . $column['column_name'] . '</th>';
                 }
             }
             if ($withApproveReject) {
                 $out .= '<th style="text-align: center;">Check</th>';
                 $out .= '<th style="text-align: center;">Approve</th>';
                 $out .= '<th style="text-align: center;">Reject</th>';
             }
             if ($show_delete) {
                 $out .= '<th style="text-align: center;">Delete</th>';
             }
             if ($show_edit) {
                 $out .= '<th style="text-align: center;">Edit</th>';
             }
             if (!$other_status) {
                 $out .= '<th style="text-align: center;">Status</th>';
             }
         }
         foreach ($array_nv as $i) {
             $text = $i[0];
             $name = $i[1];
             $type = $i[2];
             $out .= '<th>' . $text . '</th>';
         }
         if (!$inFront) {
             if (!empty($extra_columns)) {
                 foreach ($extra_columns as $column) {
                     $out .= '<th>' . $column['column_name'] . '</th>';
                 }
             }
             if ($withApproveReject) {
                 $out .= '<th style="text-align: center;">Check</th>';
                 $out .= '<th style="text-align: center;">Approve</th>';
                 $out .= '<th style="text-align: center;">Reject</th>';
             }
             if (!$other_status) {
                 $out .= '<th style="text-align: center;">Status</th>';
             }
             if ($show_edit) {
                 $out .= '<th style="text-align: center;">Edit</th>';
             }
             if ($show_delete) {
                 $out .= '<th style="text-align: center;">Delete</th>';
             }
         }
         $out .= '</thead>
                      <tbody>';
         foreach ($array_in as $a) {
             $out .= '<tr>';
             if ($inFront) {
                 if (!empty($extra_columns)) {
                     foreach ($extra_columns as $column) {
                         $out .= '<td style="text-align: center;">' . $column['column_content'] . '</td>';
                     }
                 }
                 if ($withApproveReject) {
                     $out .= '<td style="text-align: center;">
                                             <input type="checkbox" name="uid[' . $a['uid'] . ']" class="uid-checkbox" />
                                           </td>
                                           <td style="text-align: center;">
                                             <a href="' . $thisss->baseUrl('approve-reject-ob?type=' . $s_text . '&uid=' . $a['uid'] . '&status=approved&single_uid=true') . '">
                                                 <span class="glyphicon glyphicon-ok">&nbsp;</span>
                                             </a>
                                           </td>';
                     $out .= '<td style="text-align: center;">
                                             <a href="' . $thisss->baseUrl('approve-reject-ob?type=' . $s_text . '&uid=' . $a['uid'] . '&status=rejected&single_uid=true') . '">
                                                 <span class="glyphicon glyphicon-remove">&nbsp;</span>
                                             </a>
                                           </td>';
                 }
                 if ($show_delete) {
                     $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, 'deleted', $a[$del_in_value]) . '</td>';
                 }
                 if ($show_edit) {
                     $out .= '<td style="text-align: center;"><a data-table="' . $_table . '" data-title="' . $_title . '" data-id="' . $a['id'] . '" class="ajax ajax-edit-item"><img src="img/edit.png" class="img-30" /></a></td>';
                 }
                 if (!$other_status) {
                     $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, $a['status']) . '</td>';
                 }
             }
             foreach ($array_nv as $i) {
                 $text = $i[0];
                 $name = $i[1];
                 $type = $i[2];
                 switch ($type) {
                     case 'text':
                         $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . $a[$name] : ' style="text-align: center;">-') . '</td>';
                         break;
                     case 'round':
                         $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . round2Nr($a[$name]) : ' style="text-align: center;">-') . '</td>';
                         break;
                     case 'check':
                         $out .= '<td>' . ($a[$name] == 1 ? '<b>Yes</b>' : 'No') . '</td>';
                         break;
                     case 'date':
                         $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . convertUStoUKdate($a[$name]) : ' style="text-align: center;">-') . '</td>';
                         break;
                     case 'image':
                         $out .= '<td>' . NL_Render::renderImageInTbl($a[$name]) . '</td>';
                         break;
                     case 'bg_color':
                         $out .= '<td style="background-color: ' . $a[$name] . '"></td>';
                         break;
                     case 'array':
                         $out .= '<td' . (!empty($a[$name][$i[3]]) && !is_null($a[$name][$i[3]]) ? '>' . $a[$name][$i[3]] : ' style="text-align: center;">-') . '</td>';
                         break;
                     case 'link':
                         $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . '<a href="' . $i[3] . $a[$name] . '" target="_blank">
                                                 <span class="glyphicon glyphicon-print"></span> ' . $a[$name] . '</a>' : ' style="text-align: center;">-') . '</td>';
                 }
             }
             if (!$inFront) {
                 if (!empty($extra_columns)) {
                     foreach ($extra_columns as $column) {
                         $out .= '<td style="text-align: center;">' . $column['column_content'] . '</td>';
                     }
                 }
                 if (!$other_status) {
                     $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, $a['status']) . '</td>';
                 }
                 if ($show_edit) {
                     $out .= '<td style="text-align: center;"><a data-table="' . $_table . '" data-title="' . $_title . '" data-id="' . $a['id'] . '" class="ajax ajax-edit-item"><img src="img/edit.png" class="img-30" /></a></td>';
                 }
                 if ($show_delete) {
                     $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, 'deleted', $a[$del_in_value]) . '</td>';
                 }
             }
             $out .= '</tr>';
         }
         $out .= '</tbody>
                     </table>';
     } else {
         $out .= '<div class="panel">
                         <h4 style="margin-left: 10px;">No ' . (!empty($extra_text) ? strtolower($extra_text) : $table) . ' listed</h5>
                     </div>';
     }
     if ($withApproveReject) {
         $out .= "</form>\n                <script>\n                 \$(document).ready(function(){\n                    \$('.check-all').on('click', function(){\n                        \$('.uid-checkbox').prop('checked', true);\n                    });\n\n                    \$('.uncheck-all').on('click', function(){\n                        \$('.uid-checkbox').prop('checked', false);\n                    });\n                 });\n              </script>";
     }
     return $out;
 }