Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอสอบถามเรื่องการ update drag and drop ครับ CodeIgniter php



 

ขอสอบถามเรื่องการ update drag and drop ครับ CodeIgniter php

 



Topic : 129224



โพสกระทู้ ( 12 )
บทความ ( 0 )



สถานะออฟไลน์




ตัวอย่างครับ
ตัวอย่าง

form.php
Code (PHP)
<form method="post" id="form_dep_select" name="form_dep_select" onSubmit="JavaScript:return fncSubmit();" >
    
            <script type="text/javascript">
              var redipsURL = '/javascript/drag-and-drop-table-row/';
            </script>
          
            <!-- tables inside this DIV could contain drag-able content  -->
            <div id="redips-drag">

              <!-- left container -->
              <div id="left">          
                <table class="tbl0">
                  <colgroup>
                    <col width="100"/>
                  </colgroup>
                  <thead>
                    <tr>
                      <th class="redips-mark">กลุ่มA</th>
                    </tr>
                  </thead>
                </table>

                <div style="margin:0px; width:178px; height:318px; overflow: auto;">
                <table class="tbl0">
                  <tbody>                
                    <?php 
                      foreach ($transportAll_branch_set_999 as $key => $value) {
                    ?>
                    <tr class="rl">
                      <td class="redips-rowhandler"><div class="redips-drag redips-row"><?php echo $value->brAbbName; ?></div>
                        <input type="hidden" name="unit_select_dep_999" id="unit_select_dep_999" value="<?php echo $value->brParent_unit; ?>">
                        <input type="hidden" name="brAbbName_select_dep_999" id="brAbbName_select_dep_999" value="<?php echo $value->brAbbName; ?>">
                      </td>                                    
                    </tr>
                    <?php } ?>
                    <tr>
                      <td class="redips-mark"><span>Message line</span></td>
                    </tr>
                  </tbody>
                </table>
                </div>
              </div>

              <!-- middle container -->
              <div id="middle">
                <table class="tbl1">
                  <colgroup>
                    <col width="100"/>
                  </colgroup>
                  <thead>
                    <tr>
                      <th class="redips-mark">กลุ่มB</th>
                    </tr>
                  </thead>
                </table>

                <div style="margin:0px; width:178px; height:318px; overflow: auto;">
                <table class="tbl1">
                  <tbody>
                    <?php 
                      foreach ($transportAll_branch_set_1 as $key => $value) {
                    ?>
                    <tr class="rl">
                      <td class="redips-rowhandler"><div class="redips-drag redips-row"><?php echo $value->brAbbName; ?></div>
                        <input type="hidden" name="unit_select_dep_1" id="unit_select_dep_1" value="<?php echo $value->brParent_unit; ?>">
                        <input type="hidden" name="brAbbName_select_dep_1" id="brAbbName_select_dep_1" value="<?php echo $value->brAbbName; ?>">
                      </td>              
                    </tr>
                    <?php } ?>
                    <tr>
                      <td class="redips-mark"><span>Message line</span></td>
                    </tr>
                  </tbody>
                </table>
                </div>
              </div>

              <!-- middle container -->
              <div id="middle">
                <table class="tbl2">
                  <colgroup>
                    <col width="100"/>
                  </colgroup>
                  <thead>
                    <tr>
                      <th class="redips-mark">กลุ่มC</th>
                    </tr>
                  </thead>
                </table>

                <div style="margin:0px; width:178px; height:318px; overflow: auto;">
                <table class="tbl2">              
                  <tbody>              
                    <?php 
                      foreach ($transportAll_branch_set_2 as $key => $value) {
                    ?>
                    <tr class="rl">
                      <td class="redips-rowhandler"><div class="redips-drag redips-row"><?php echo $value->brAbbName; ?></div>
                        <input type="hidden" name="unit_select_dep_2" id="unit_select_dep_2" value="<?php echo $value->brParent_unit; ?>">
                        <input type="hidden" name="brAbbName_select_dep_2" id="brAbbName_select_dep_2" value="<?php echo $value->brAbbName; ?>">
                      </td>
                    </tr>
                    <?php } ?>
                    <tr>
                      <td class="redips-mark"><span>Message line</span></td>
                    </tr>
                  </tbody>
                </table>
                </div>
              </div>

              <!-- middle container -->
              <div id="middle">        
                <table class="tbl3">
                  <colgroup>
                    <col width="100"/>
                  </colgroup>
                  <thead>
                    <tr>
                      <th class="redips-mark">กลุ่มD</th>
                    </tr>
                  </thead>
                </table>

                <div style="margin:0px; width:178px; height:318px; overflow: auto;">
                <table class="tbl3">
                  <tbody>                
                    <?php 
                      foreach ($transportAll_branch_set_3 as $key => $value) {
                    ?>
                    <tr class="rl">
                      <td class="redips-rowhandler"><div class="redips-drag redips-row"><?php echo $value->brAbbName; ?></div>
                        <input type="hidden" name="unit_select_dep_3" id="unit_select_dep_3" value="<?php echo $value->brParent_unit; ?>">
                        <input type="hidden" name="brAbbName_select_dep_3" id="brAbbName_select_dep_3" value="<?php echo $value->brAbbName; ?>">
                      </td>
                    </tr>
                    <?php } ?>
                    <tr>
                      <td class="redips-mark"><span>Message line</span></td>
                    </tr>
                  </tbody>
                </table>
                </div>          
              </div>
             </div>
          
            <div class="box-footer text-center">                
              <input type="submit" name="from_update_dep_select" id="from_update_dep_select" class="btn btn-primary btn-sm" style="width:75px;height:35px" value="บันทึก" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="button" class="btn btn-primary btn-sm" style="width:75px;height:35px" value="ล้างข้อมูล" onClick="javascript: window.location.reload()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </div>
            </form>


update.php
Code (PHP)
public function update_from_dep_select()
        {
            $code_select_dep_999=$this->input->post('unit_select_dep_999');
            $br_abbName_select_dep_999=$this->input->post('brAbbName_select_dep_999');

            $code_select_dep_1=$this->input->post('unit_select_dep_1');       
            $br_abbName_select_dep_1=$this->input->post('brAbbName_select_dep_1');  

            $code_select_dep_2=$this->input->post('unit_select_dep_2');
            $br_abbName_select_dep_2=$this->input->post('brAbbName_select_dep_2');

            $code_select_dep_3=$this->input->post('unit_select_dep_3');    
            $br_abbName_select_dep_3=$this->input->post('brAbbName_select_dep_3');  

            $code_select_dep_4=$this->input->post('unit_select_dep_4'); 
            $br_abbName_select_dep_4=$this->input->post('brAbbName_select_dep_4');

            ////////////////////////  dep_select_999 dep_select_999 ////////////////////////////////
            ////////////////////////  dep_select_999 dep_select_999 ////////////////////////////////

            if($code_select_dep_999 == 999){                
                $sql_dep_select_999 = "SELECT * FROM `branch` WHERE `brAbbName` = '$br_abbName_select_dep_999'";
                $query_dep_select_999 = $this->db->query("$sql_dep_select_999");
                $result_dep_select_999=$query_dep_select_999->result_array();
                foreach ($result_dep_select_999 as $row_dep_select_999){  
                    $br_code=$row_dep_select_999["brCode"];            
                }
                $this->db->set('brParent_unit', 999);
                $this->db->where('brCode', $br_code);
                $this->db->update("branch");
            }

            ////////////////////////  dep_select_1 dep_select_1 ////////////////////////////////
            ////////////////////////  dep_select_1 dep_select_1 ////////////////////////////////

            if($code_select_dep_1 == 1){
                $sql_dep_select_1 = "SELECT * FROM `branch` WHERE `brAbbName` = '$br_abbName_select_dep_1'";
                $query_dep_select_1 = $this->db->query("$sql_dep_select_1");
                $result_dep_select_1=$query_dep_select_1->result_array();
                foreach ($result_dep_select_1 as $row_dep_select_1){  
                    $br_code=$row_dep_select_1["brCode"];            
                }
                $this->db->set('brParent_unit', 1);
                $this->db->where('brCode', $br_code);
                $this->db->update('branch');
            }

            ////////////////////////  dep_select_2 dep_select_2 ////////////////////////////////
            ////////////////////////  dep_select_2 dep_select_2 ////////////////////////////////

            if($code_select_dep_2 == 2){
                $sql_dep_select_2 = "SELECT * FROM `branch` WHERE `brAbbName` = '$br_abbName_select_dep_2'";
                $query_dep_select_2 = $this->db->query("$sql_dep_select_2");
                $result_dep_select_2=$query_dep_select_2->result_array();
                foreach ($result_dep_select_2 as $row_dep_select_2){  
                    $br_code=$row_dep_select_2["brCode"];            
                }
                $this->db->set('brParent_unit', 2);
                $this->db->where('brCode', $br_code);
                $this->db->update('branch');
            }

            ////////////////////////  dep_select_3 dep_select_3 ////////////////////////////////
            ////////////////////////  dep_select_3 dep_select_3 ////////////////////////////////

            if($code_select_dep_3 == 3){
                $sql_dep_select_3 = "SELECT * FROM `branch` WHERE `brAbbName` = '$br_abbName_select_dep_3'";
                $query_dep_select_3 = $this->db->query("$sql_dep_select_3");
                $result_dep_select_3=$query_dep_select_3->result_array();
                foreach ($result_dep_select_3 as $row_dep_select_3){  
                    $br_code=$row_dep_select_3["brCode"];            
                }
                $this->db->set('brParent_unit', 3);
                $this->db->where('brCode', $br_code);
                $this->db->update('branch');
            }

            ////////////////////////  dep_select_4 dep_select_4 ////////////////////////////////
            ////////////////////////  dep_select_4 dep_select_4 ////////////////////////////////

            if($code_select_dep_4 == 4){
                $sql_dep_select_4 = "SELECT * FROM `branch` WHERE `brAbbName` = '$br_abbName_select_dep_4'";
                $query_dep_select_4 = $this->db->query("$sql_dep_select_4");
                $result_dep_select_4=$query_dep_select_4->result_array();
                foreach ($result_dep_select_4 as $row_dep_select_4){  
                    $br_code=$row_dep_select_4["brCode"];
                }
                $this->db->set('brParent_unit', 4);
                $this->db->where('brCode', $br_code);
                $this->db->update('branch');
            }

            redirect("backend/from_select_dep","refresh");
            exit();


           
        }



script.js
Code (JavaScript)

/*jslint white: true, browser: true, undef: true, nomen: true, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxerr: 14 */
/*global window: false, REDIPS: true */

/* enable strict mode */
"use strict";

// define redipsInit variable
var redipsInit;

// redips initialization
redipsInit = function () {
	// reference to the REDIPS.drag library and message line
	var	rd = REDIPS.drag,
		msg;
	// initialization
	rd.init();
	// set hover color for TD and TR
	rd.hover.colorTd = '#FFCFAE';
	rd.hover.colorTr = '#9BB3DA';
	// set hover border for current TD and TR
	rd.hover.borderTd = '2px solid #32568E';
	rd.hover.borderTr = '2px solid #32568E';
	// drop row after highlighted row (if row is dropped to other tables)
	rd.rowDropMode = 'after';
	// row was clicked - event handler
	rd.event.rowClicked = function () {
		// set current element (this is clicked TR)
		var el = rd.obj;
		// find parent table
		el = rd.findParent('TABLE', el);
		// every table has only one SPAN element to display messages
		msg = el.getElementsByTagName('span')[0];
		// display message
		msg.innerHTML = 'Clicked';
	};
	// row was moved - event handler
	rd.event.rowMoved = function () {
		// set opacity for moved row
		// rd.obj is reference of cloned row (mini table)
		rd.rowOpacity(rd.obj, 85);
		// set opacity for source row and change source row background color
		// rd.objOld is reference of source row
		rd.rowOpacity(rd.objOld, 20, 'White');
		// display message
		msg.innerHTML = 'Moved';
	};
	// row was not moved - event handler
	rd.event.rowNotMoved = function () {
		msg.innerHTML = 'Not moved';
	};
	// row was dropped - event handler
	rd.event.rowDropped = function () {
		// display message
		msg.innerHTML = 'Dropped';
	};
	// row was dropped to the source - event handler
	// mini table (cloned row) will be removed and source row should return to original state
	rd.event.rowDroppedSource = function () {
		// make source row completely visible (no opacity)
		rd.rowOpacity(rd.objOld, 100);
		// display message
		msg.innerHTML = 'Dropped to the source';
	};
	/*
	// how to cancel row drop to the table
	rd.event.rowDroppedBefore = function () {
		//
		// JS logic
		//
		// return source row to its original state
		rd.rowOpacity(rd.objOld, 100);
		// cancel row drop
		return false;
	}
	*/
	// row position was changed - event handler
	rd.event.rowChanged = function () {
		// get target and source position (method returns positions as array)
		var pos = rd.getPosition();
		// display current table and current row
		msg.innerHTML = 'Changed: ' + pos[0] + ' ' + pos[1];
	};
};


// add onload event listener
if (window.addEventListener) {
	window.addEventListener('load', redipsInit, false);
}
else if (window.attachEvent) {
	window.attachEvent('onload', redipsInit);
}



คำถาม

1. อยากทราบว่าเมื่อเราจัดย้ายกลุ่มเสร็จแล้ว เมื่อกดบันทึก จะให้ update ข้อมูลเป็นของแต่ละกลุ่ม ครับ
เช่น
ข้อมูลที่อยู่ กลุ่มA ให้ update unit เป็น 1
ข้อมูลที่อยู่ กลุ่มB ให้ update unit เป็น 2
ข้อมูลที่อยู่ กลุ่มC ให้ update unit เป็น 3
ข้อมูลที่อยู่ กลุ่มD ให้ update unit เป็น 4
ประมาณนี้ครับ

2. หรืออีกวิธี ช่วยแนะนำ code แบบว่า พอลากข้อมูลไปกลุ่มไหน ก็ให้ update unit เป็นของกลุ่มนั้นไปเลย ต้องทำยังไงครับ



Tag : PHP, MySQL, JavaScript, MVC, CodeIgniter









ประวัติการแก้ไข
2017-10-16 11:26:43
2017-10-16 11:26:59
2017-10-16 19:53:46
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-10-16 11:23:08 By : StyleIndy View : 1023 Reply : 1
 

 

No. 1



โพสกระทู้ ( 12 )
บทความ ( 0 )



สถานะออฟไลน์


รบกวนผู้รู้ช่วยทีนะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-10-16 22:33:43 By : StyleIndy
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอสอบถามเรื่องการ update drag and drop ครับ CodeIgniter php
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่