usergroupsedit.blade.php.bak 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. @extends('admin.master')
  2. @section('content')
  3. <?php
  4. if ($operdata == "") {
  5. //Insert Mode
  6. $_name = "";
  7. $_valid = "1";
  8. } else {
  9. //Edit Mode
  10. foreach ($operdata as $data_item1) {
  11. $_serno = $data_item1->id;
  12. $_name = $data_item1->Name;
  13. $_valid = $data_item1->Valid;
  14. $_cdate = $data_item1->created_at;
  15. $_mdate = $data_item1->updated_at;
  16. $_oid = $data_item1->Oid;
  17. }
  18. }
  19. ?>
  20. <div class="row">
  21. <div class="col-lg-12">
  22. <form id="EditForm" class="form-horizontal" method="post" action="{{ url('/Backend/Usergroups/store') }}">
  23. {{ csrf_field() }}
  24. <div class="panel panel-primary">
  25. <div class="panel-heading">
  26. <h4 class="panel-title">{{ (($operdata == "") ? "Create " : "Modify ") }}Group</h4>
  27. </div>
  28. <div class="panel-body">
  29. <div>
  30. <!-- 表格本體 -->
  31. <table class="table" cellspacing="0" id="DetailsView1" style="border-collapse:collapse;">
  32. <tbody>
  33. <!-- 欄位:no -->
  34. @if ($operdata == "")
  35. <!-- Insert Mode -->
  36. <input type="hidden" name="mode" value="insert" />
  37. @else
  38. <!-- Edit Mode -->
  39. <tr>
  40. <td class="col-lg-2">no</td>
  41. <td>
  42. <input name="id" type="hidden" value="{{ $_serno }}" id="serno" />
  43. {{ $_serno }}
  44. </td>
  45. </tr>
  46. @endif
  47. <!-- 欄位:Group Name -->
  48. <!-- ALL Mode -->
  49. <tr>
  50. <td class="header-require col-lg-2">Group Name</td>
  51. <td>
  52. <div class="col-lg-3 nopadding">
  53. <input name="Name" type="text" value="{{ $_name }}" maxlength="20" id="name" class="form-control">
  54. <label class="error" for="name"></label>
  55. </div>
  56. </td>
  57. </tr>
  58. <!-- 欄位:Valid -->
  59. <!-- ALL Mode -->
  60. <tr>
  61. <td class="col-lg-2">Valid</td>
  62. <td>
  63. <input id="valid" type="checkbox" name="Valid" {{ ($_valid=='1')?"checked='checked'":"" }} />
  64. </td>
  65. </tr>
  66. <!-- 欄位:Create Time -->
  67. @if ($operdata == "")
  68. <!-- Insert Mode -->
  69. @else
  70. <!-- Edit Mode -->
  71. <tr>
  72. <td class="col-lg-2">Create Time</td>
  73. <td>{{ $_cdate }}</td>
  74. </tr>
  75. @endif
  76. <!-- 欄位:Modify Time -->
  77. @if ($operdata == "")
  78. <!-- Insert Mode -->
  79. @else
  80. <!-- Edit Mode -->
  81. <tr>
  82. <td class="col-lg-2">Modify Time</td>
  83. <td>{{ $_mdate }}</td>
  84. </tr>
  85. @endif
  86. <!-- 欄位:Role -->
  87. @if ($operdata == "")
  88. <!-- Insert Mode -->
  89. @else
  90. <!-- Edit Mode -->
  91. <tr>
  92. <td class="col-lg-2">Role</td>
  93. <td><span id="oid">{{ $_oid }}</span></td>
  94. </tr>
  95. @endif
  96. <!-- 欄位:Functions -->
  97. <!-- ALL Mode -->
  98. <tr>
  99. <td class="col-lg-2">Functions</td>
  100. <td>
  101. <!-- 左側Source區 -->
  102. <div class="col-md-4">
  103. <table>
  104. <tbody>
  105. <tr style="text-align: center">
  106. <td style="background-color: #cccccc" class="nopadding">Source</td>
  107. </tr>
  108. <tr>
  109. <td class="nopadding">
  110. <select size="4" name="fFunAll" multiple="multiple" id="fFunAll" style="height:160px;width:160px;">
  111. @foreach($unseleted_funlist as $data)
  112. <option value='{{ $data->id }}'>{{ $data->FunName }}</option>
  113. @endforeach
  114. </select>
  115. </td>
  116. </tr>
  117. </tbody>
  118. </table>
  119. </div>
  120. <!-- 中間的轉換按鈕 -->
  121. <div class="col-md-2">
  122. <table>
  123. <tbody>
  124. <tr style="text-align: center">
  125. <td style="width: 80px" class="nopadding">&nbsp;</td>
  126. </tr>
  127. <tr>
  128. <td style="text-align: center">
  129. <input type="button" name="btnAllSelect" value=" >> " id="btnAllSelect" class="btn btn-default form-control btn-xs">
  130. <br>
  131. <input type="button" name="btnSelect" value=" > " id="btnSelect" class="btn btn-default form-control btn-xs">
  132. <br>
  133. <input type="button" name="btnRomove" value=" < " id="btnRomove" class="btn btn-default form-control btn-xs">
  134. <br>
  135. <input type="button" name="btnAllRomove" value=" << " id="btnAllRomove" class="btn btn-default form-control btn-xs">
  136. <br>
  137. </td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. </div>
  142. <!-- 右側Destination區 -->
  143. <div class="col-md-4">
  144. <table>
  145. <tbody>
  146. <tr style="text-align: center">
  147. <td style="background-color: #cccccc" class="nopadding">Destination</td>
  148. </tr>
  149. <tr>
  150. <td class="nopadding">
  151. <select size="4" name="FunList" multiple="multiple" id="funlist" style="height:160px;width:160px;">
  152. @foreach($seleted_funlist as $data)
  153. <option value='{{ $data->id }}'>{{ $data->FunName }}</option>
  154. @endforeach
  155. </select>
  156. </td>
  157. </tr>
  158. </tbody>
  159. </table>
  160. </div>
  161. <!-- 右側的隱藏控制表單項 -->
  162. <input type="hidden" id="hidfunlist" name ="hidfunlist"></input>
  163. </td>
  164. </tr>
  165. <!-- 欄位:Role -->
  166. <!-- ALL Mode -->
  167. <tr>
  168. <td class="col-lg-2">Role</td>
  169. <td>
  170. <!-- 左側Source區 -->
  171. <div class="col-md-4">
  172. <table>
  173. <tbody>
  174. <tr style="text-align: center">
  175. <td style="background-color: #cccccc" class="nopadding">Source</td>
  176. </tr>
  177. <tr>
  178. <td class="nopadding">
  179. <select size="4" name="fUsrAll" multiple="multiple" id="fUsrAll" style="height:160px;width:160px;">
  180. @foreach($unseleted_usrlist as $data)
  181. <option value='{{ $data->id }}'>{{ $data->name }}({{ $data->email }})</option>
  182. @endforeach
  183. </select>
  184. </td>
  185. </tr>
  186. </tbody>
  187. </table>
  188. </div>
  189. <!-- 中間的轉換按鈕 -->
  190. <div class="col-md-2">
  191. <table>
  192. <tbody>
  193. <tr style="text-align: center">
  194. <td style="width: 80px" class="nopadding">&nbsp;</td>
  195. </tr>
  196. <tr>
  197. <td style="text-align: center">
  198. <input type="button" name="btnAllSelect" value=" >> " id="UbtnAllSelect" class="btn btn-default form-control btn-xs">
  199. <br>
  200. <input type="button" name="btnSelect" value=" > " id="UbtnSelect" class="btn btn-default form-control btn-xs">
  201. <br>
  202. <input type="button" name="btnRomove" value=" < " id="UbtnRomove" class="btn btn-default form-control btn-xs">
  203. <br>
  204. <input type="button" name="btnAllRomove" value=" << " id="UbtnAllRomove" class="btn btn-default form-control btn-xs">
  205. <br>
  206. </td>
  207. </tr>
  208. </tbody>
  209. </table>
  210. </div>
  211. <!-- 右側Destination區 -->
  212. <div class="col-md-4">
  213. <table>
  214. <tbody>
  215. <tr style="text-align: center">
  216. <td style="background-color: #cccccc" class="nopadding">Destination</td>
  217. </tr>
  218. <tr>
  219. <td class="nopadding">
  220. <select size="4" name="UsrList" multiple="multiple" id="usrlist" style="height:160px;width:160px;">
  221. @foreach($seleted_usrlist as $data)
  222. <option value='{{ $data->id }}'>{{ $data->name }}({{ $data->email }})</option>
  223. @endforeach
  224. </select>
  225. </td>
  226. </tr>
  227. </tbody>
  228. </table>
  229. </div>
  230. <!-- 右側的隱藏控制表單項 -->
  231. <input type="hidden" id="hidusrlist" name ="hidusrlist"></input>
  232. </td>
  233. </tr>
  234. <!-- 下控制按鈕 -->
  235. <tr>
  236. <td>&nbsp;</td>
  237. <td>
  238. <div style="text-align: right">
  239. @if ($operdata == "")
  240. <!-- Insert Mode -->
  241. <input type="button" name="btnUpdate_foot" value="Create" id="btnUpdate_foot" class="btn btn-primary btn-xs" onclick="submitForm();">
  242. @else
  243. <!-- Edit Mode -->
  244. <input type="button" name="btnUpdate_foot" value="Modify" id="btnUpdate_foot" class="btn btn-primary btn-xs" onclick="submitForm();">
  245. @endif
  246. <input type="button" name="btnBackTo2_foot" value="Back" id="btnBackTo2_foot" class="btn btn-default btn-xs">
  247. </div>
  248. </td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. </div>
  253. </div>
  254. <!-- panel-body -->
  255. </div>
  256. </form>
  257. </div>
  258. </div>
  259. @endsection
  260. @section('extjs')
  261. <script>
  262. $(document).ready(function() {
  263. //Functions:單個項目指派
  264. $("#btnSelect").click(function() {
  265. $("#fFunAll option:selected").each(function() {
  266. $("#funlist").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  267. });
  268. $("#fFunAll option:selected").remove();
  269. });
  270. //Functions:單個項目移除
  271. $("#btnRomove").click(function() {
  272. $("#funlist option:selected").each(function() {
  273. $("#fFunAll").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  274. });
  275. $("#funlist option:selected").remove();
  276. });
  277. //Functions:所有項目指派
  278. $("#btnAllSelect").click(function() {
  279. $("#fFunAll option").each(function() {
  280. $("#funlist").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  281. });
  282. $("#fFunAll option").remove();
  283. });
  284. //Functions:所有項目移除
  285. $("#btnAllRomove").click(function() {
  286. $("#funlist option").each(function() {
  287. $("#fFunAll").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  288. });
  289. $("#funlist option").remove();
  290. });
  291. //Role:單個項目指派
  292. $("#UbtnSelect").click(function() {
  293. $("#fUsrAll option:selected").each(function() {
  294. $("#usrlist").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  295. });
  296. $("#fUsrAll option:selected").remove();
  297. });
  298. //Role:單個項目移除
  299. $("#UbtnRomove").click(function() {
  300. $("#usrlist option:selected").each(function() {
  301. $("#fUsrAll").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  302. });
  303. $("#usrlist option:selected").remove();
  304. });
  305. //Role:所有項目指派
  306. $("#UbtnAllSelect").click(function() {
  307. $("#fUsrAll option").each(function() {
  308. $("#usrlist").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  309. });
  310. $("#fUsrAll option").remove();
  311. });
  312. //Role:所有項目移除
  313. $("#UbtnAllRomove").click(function() {
  314. $("#usrlist option").each(function() {
  315. $("#fUsrAll").append('<option value="'+$(this).val()+'" >'+ $( this ).text()+'</option>');
  316. });
  317. $("#usrlist option").remove();
  318. });
  319. //Back
  320. $("#btnBackTo2").click(function() {
  321. location.href='/Backend/Usergroups';
  322. });
  323. $("#btnBackTo2_foot").click(function() {
  324. location.href='/Backend/Usergroups';
  325. });
  326. //初始化需要偵錯的表格
  327. $('#EditForm').validate();
  328. //正規表達驗證初始化
  329. $.validator.addMethod(
  330. "regex",
  331. function (value, element, regexp) {
  332. var re = new RegExp(regexp);
  333. return this.optional(element) || re.test(value);
  334. }
  335. );
  336. //各欄位
  337. $('#name').rules("add", {
  338. required: true,
  339. minlength: 1,
  340. maxlength: 20,
  341. messages: {
  342. required: "Group Name length must between 1-20",
  343. minlength: "Group Name length must between 1-20",
  344. maxlength: "Group Name length must between 1-20"
  345. }
  346. });
  347. });
  348. //提交與取消按鈕
  349. function submitForm() {
  350. if (!!($("#EditForm").valid()) === false) {
  351. return false;
  352. } else {
  353. $(document).ready(function() {
  354. $.blockUI({ css: {
  355. border: 'none',
  356. padding: '15px',
  357. backgroundColor: '#000',
  358. '-webkit-border-radius': '10px',
  359. '-moz-border-radius': '10px',
  360. opacity: .5,
  361. color: '#fff'
  362. }});
  363. });
  364. }
  365. $(document).ready(function() {
  366. //Functions的加工
  367. var funlist='';
  368. $("#funlist option").each(function(){
  369. funlist += $(this).val() + "," ;
  370. });
  371. $("#hidfunlist").val(funlist);
  372. //Role的加工
  373. var usrlist='';
  374. $("#usrlist option").each(function(){
  375. usrlist += $(this).val() + "," ;
  376. });
  377. $("#hidusrlist").val(usrlist);
  378. $("#EditForm").submit();
  379. });
  380. }
  381. function cancelValidate() {
  382. $("#EditForm").validate().cancelSubmit = true;
  383. }
  384. </script>
  385. @endsection