Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. <?php
  2. include_once '../session.php';
  3. include_once '../config.php';
  4. $pagetitle="الشركات";
  5. include_once "../header.php";
  6. if (isset($_POST['add_new_comp'])) {
  7. $check_data_companies = row_one('companies',"name='".$_POST['name']."'","");
  8. if(empty($check_data_companies)){
  9. $val = array();
  10. $id= generate_rand_num("companies", "id", 1, 8, 4, 2);
  11. $val['id'] =$id;
  12. $val['name'] = $_POST['name'];
  13. $val['created_at'] = date('Y-m-d H:i:s');
  14. Insertdb("companies", $val);
  15. $response="تم إضافة الشركه بنجاح";
  16. }
  17. }
  18. //delete
  19. if (isset($_POST["delete_comp"])) {
  20. $get_info_admin=row_one('companies',"id='".$_POST['comp_id']."'","");
  21. $val = array();
  22. Del("companies", "id='".$_POST["comp_id"]."'");
  23. $response="تم حذف الشركه بنجاح";
  24. }
  25. //show
  26. if(isset($_GET['page_id'])) { $pid = $_GET['page_id']; }else{ $pid = 0; }
  27. if(isset($_POST['search'])){
  28. $WHERE = "WHERE (".get_cols_using_LIKE("companies", $_POST['search_text']).")";
  29. }else{
  30. $WHERE = "";
  31. }
  32. $get_companies = Pager("companies $WHERE","companies_page=",$pid,1,200,"created_at DESC");
  33. ?>
  34. <div class="wrapper">
  35. <div class="container-fluid">
  36. <div class="row">
  37. <div class="col-12">
  38. <div class="page-title-box">
  39. <div class="page-title-right">
  40. </div>
  41. <h4 class="page-title">الشركات</h4>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="row">
  46. <div class="col-lg-12">
  47. <div class="card-box">
  48. <?php if(!empty($response)){echo create_alert("info",$response,"");}?>
  49. <form method="post">
  50. <div class="row">
  51. <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
  52. <div class="form-group">
  53. <?php echo tag_modal("add_new_comp","btn btn-success","fa fa-plus","إضافـة شركة جديدة");?>
  54. </div>
  55. </div>
  56. <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
  57. <div class="form-group">
  58. <input type="text" class="form-control" name="search_text" placeholder="إسـم الشركة">
  59. </div>
  60. </div>
  61. <div class="col-lg-2 col-md-2 col-sm-6 col-xs-6">
  62. <div class="form-group">
  63. <button type="submit" name="search" class="btn btn-danger"> <span class="fa fa-search"></span> بحث وعرض </button>
  64. </div>
  65. </div>
  66. <div class="col-lg-2 col-md-2 col-sm-6 col-xs-6">
  67. <div class="form-group">
  68. <p class="btn btn-danger" style="background-color: #435966 !important; border-color:#435966 !important;">
  69. <span class="fas fa-user-friends"></span>
  70. <?php
  71. echo NUM_with_Text(
  72. NUM("companies",""),
  73. "شركه",
  74. "شركه واحـده",
  75. "شركتان",
  76. "شركات",
  77. "لا توجد شركات حتى الآن"
  78. );
  79. ?>
  80. </p>
  81. </div>
  82. </div>
  83. </div>
  84. </form>
  85. <?php
  86. if(NUM("companies","") == 0){
  87. echo "<center>";
  88. echo "لا توجد شركات حتى الآن";
  89. echo "</center>";
  90. }else{
  91. if(!empty($get_companies[1])){echo '<hr>';} echo $get_companies[1]; if(!empty($get_companies[1])){echo '<hr>';} ?>
  92. <div class="table-responsive">
  93. <table class="table table-bordered mobile_tables mb-0">
  94. <thead>
  95. <tr>
  96. <th>#</th>
  97. <th>إسـم الشركة</th>
  98. <th>أُضيـفت فـي</th>
  99. <th>الإجـراءات</th>
  100. </tr>
  101. </thead>
  102. <tbody>
  103. <?php
  104. foreach ($get_companies as $companies):
  105. if (is_array($companies) or is_object($companies)){
  106. foreach ($companies as $counetr => $get_info_company):?>
  107. <tr>
  108. <td class="text-center" data-title="#"><?php echo $counetr+1; ?></td>
  109. <td data-title="إسـم الشركه"><?php echo $get_info_company['name'];?></td>
  110.  
  111. <td data-title="أُضيفت في"><?php echo datetime_to_string_ar($get_info_company['created_at']);?></td>
  112. <td data-title="الإجرائات">
  113. <?php
  114.  
  115. echo tag_modal("delete_comp_".$get_info_company['id'],"btn btn-xs btn-danger","mdi mdi-trash-can-outline","");
  116. ?>
  117. </td>
  118. </tr>
  119. <?php
  120. endforeach;
  121. }
  122. endforeach;
  123. ?>
  124. </tbody>
  125. </table>
  126. </div>
  127. <?php }
  128. if(!empty($get_companies[1])){echo '<hr>';} echo $get_companies[1]; if(!empty($get_companies[1])){echo '<hr>';} ?>
  129. </div>
  130. </div>
  131. </div>
  132. <?php
  133. foreach ($get_companies as $companies):
  134. if (is_array($companies) or is_object($companies)){
  135. foreach ($companies as $counetr => $get_info_company):
  136. $add_new_requirement_body= '
  137. <div class="form-group">
  138. <label> هـل تـرغب بـحذف الشركه ؟</label>
  139. </div>';
  140. echo create_modal(
  141. "delete_comp_".$get_info_company['id'],
  142. '',
  143. 'حذف الشركه ('.$get_info_company['name'].')',
  144. $add_new_requirement_body,
  145. 'POST',
  146. '',
  147. '',
  148. 'delete_comp',
  149. 'btn btn-xs btn-success',
  150. 'نعـم',
  151. 'btn btn-xs btn-danger',
  152. 'لا',
  153. create_input('','hidden','comp_id',$get_info_company['id'],"","")
  154. );
  155. endforeach;
  156. }
  157. endforeach;
  158. $add_new_requirement_body= '
  159. <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
  160. '.create_input('إسـم الشركه','text','name','','form-control','').'
  161. </div>';
  162. echo create_modal(
  163. 'add_new_comp',
  164. '',
  165. 'إضافـة شركه جديدة',
  166. $add_new_requirement_body,
  167. 'POST',
  168. '',
  169. '',
  170. 'add_new_comp',
  171. 'btn btn-xs btn-primary',
  172. 'إضافـة البـيانات',
  173. 'btn btn-xs btn-warning',
  174. 'إغـلاق النافـذة',
  175. '');
  176. ?>
  177. </div>
  178. </div>
  179. <?php include_once "../footer.php";?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement