Spaces:
Running
Running
File size: 9,273 Bytes
971eb1e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | <?php
/*
* Author = Dian Hermanto
* Create Date = 23 Desember 2015
* File Name = c_sync_db.php
* Function = -
* Location = -
*/
class C_sync_db extends CI_Controller
{
function index()
{
$sqlApp = "SELECT * FROM tappname";
$resultaApp = $this->db->query($sqlApp)->result();
foreach($resultaApp as $therow) :
$appName = $therow->app_name;
endforeach;
$url = site_url('c_help/c_sync_db/sync_db_idx/?id='.$this->url_encryption_helper->encode_url($appName));
redirect($url);
}
function sync_db_idx()
{
$DefEmp_ID = $this->session->userdata['Emp_ID'];
if ($this->session->userdata('login') == TRUE)
{
$idAppName = $_GET['id'];
$appName = $this->url_encryption_helper->decode_url($idAppName);
$data['title'] = $appName;
$data['h1_title'] = 'Sync';
$data['h2_title'] = 'Sync';
$data['h3_title'] = 'Database';
//return false;
// UPDATE tbl_employee
/*$IMP_N = "SELECT KOLOM0, KOLOM1, KOLOM2, KOLOM21, KOLOM22, KOLOM3, KOLOM4, KOLOM5, KOLOM6, KOLOM7
FROM tbl_import";
$ResIMP_N = $this->db->query($IMP_N)->result();
$theRow = 0;
foreach($ResIMP_N as $rowIMP_N) :
$theRow = $theRow + 1;
$KOLOM1 = $rowIMP_N->KOLOM1; // EMP_ID
$KOLOM7 = $rowIMP_N->KOLOM7; // ID NO
$IMP_CN = "tbl_employee WHERE Emp_ID = '$KOLOM1'";
$ResIMP_CN = $this->db->count_all($IMP_CN);
if($ResIMP_CN > 0)
{
$UPD_IMP_N = "UPDATE tbl_employee SET EmpNoIdentity = '$KOLOM7' WHERE Emp_ID = '$KOLOM1'";
$this->db->query($UPD_IMP_N);
echo "$theRow = update<br>";
}
else
{
echo "$theRow = input<br>";
$KOLOM2 = $rowIMP_N->KOLOM2; // NAMA AWAL
$KOLOM21 = $rowIMP_N->KOLOM21; // NAMA TENGAH
$KOLOM22 = $rowIMP_N->KOLOM22; // NAMA AKHIR
if($KOLOM21 == '' && $KOLOM22 == '')
$KOLOM23= ""; // NAMA AKHIR
elseif($KOLOM21 != '' && $KOLOM22 == '')
$KOLOM23= "$KOLOM21"; // NAMA AKHIR
elseif($KOLOM21 != '' && $KOLOM22 != '')
$KOLOM23= "$KOLOM21 $KOLOM22"; // NAMA AKHIR
$KOLOM3 = $rowIMP_N->KOLOM3; // PROYEK
$KOLOM4 = $rowIMP_N->KOLOM4; // DIVISI
$KOLOM5 = $rowIMP_N->KOLOM5; // TMP. LAHIR
$KOLOM6 = $rowIMP_N->KOLOM6; // TGL. LAHIR
// INSERT NEW
$INS_IMP_N = "INSERT INTO tbl_employee
(Emp_ID, EmpNoIdentity, Position_ID, First_Name, Last_Name, gender, Birth_Place, Email, Religion, Emp_DeptCode, log_username, log_passHint, log_password, FlagUSER, Employee_status, Emp_Location, writeEMP, editEMP, readEMP, new_stat)
VALUES ('$KOLOM1', '$KOLOM7', 3, '$KOLOM2', '$KOLOM23', 'male', '$KOLOM5', 'mail.sample@nusakonstruksi.com', 'Islam', 6, '$KOLOM1', 'GENUSR', 'c33367701511b4f6020ec61ded352059', 'APPUSR', 1, 1, 0, 0, 1, 1)";
$this->db->query($INS_IMP_N);
// INSERT EMP PROJ
$INS_IMP_O = "INSERT INTO tbl_employee_proj (Emp_ID, proj_Code) VALUES ('$KOLOM1', 'KTR')";
$this->db->query($INS_IMP_O);
// INSERT OTHER
$INS_IMP_O = "INSERT INTO others (NK, U, P) VALUES ('$KOLOM1', '$KOLOM1', '654321')";
$this->db->query($INS_IMP_O);
// INSERT MENU
$INS_IMP_O = "INSERT INTO tusermenu (isChkDetail, emp_id, menu_code) VALUES (261, '$KOLOM1', 'MN268')";
$this->db->query($INS_IMP_O);
}
endforeach;*/
//$this->load->view('v_help/v_task_request/task_request', $data);
// UPDATE tbl_others
/*$TBL_A = "SELECT Emp_ID, Emp_Notes FROM tbl_employee WHERE Emp_Notes != ''";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
foreach($ResTBL_A as $rowTBL_A) :
$Emp_ID = $rowTBL_A->Emp_ID; // EMP_ID
$Emp_Notes = $rowTBL_A->Emp_Notes; // EMP_ID
$UPD_TBL_B = "UPDATE others SET NK = '$Emp_ID' WHERE NK = '$Emp_Notes'";
$this->db->query($UPD_TBL_B);
echo "$theRow = update<br>";
endforeach;*/
// UPDATE tbl_employee_proj
/*$TBL_A = "SELECT Emp_ID, Emp_Notes FROM tbl_employee WHERE Emp_Notes != ''";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
foreach($ResTBL_A as $rowTBL_A) :
$Emp_ID = $rowTBL_A->Emp_ID; // EMP_ID
$Emp_Notes = $rowTBL_A->Emp_Notes; // EMP_ID
$UPD_TBL_B = "UPDATE tbl_employee_proj SET Emp_ID = '$Emp_ID' WHERE Emp_ID = '$Emp_Notes'";
$this->db->query($UPD_TBL_B);
echo "$theRow = update<br>";
endforeach;*/
// UPDATE tbl_employee_proj
/*$TBL_A = "SELECT Emp_ID, Emp_Notes FROM tbl_employee WHERE Emp_Notes != ''";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
foreach($ResTBL_A as $rowTBL_A) :
$Emp_ID = $rowTBL_A->Emp_ID; // EMP_ID
$Emp_Notes = $rowTBL_A->Emp_Notes; // EMP_ID
$UPD_TBL_B = "UPDATE tusermenu SET emp_id = '$Emp_ID' WHERE emp_id = '$Emp_Notes'";
$this->db->query($UPD_TBL_B);
echo "$theRow = update<br>";
endforeach;*/
// UPDATE tbl_employee username
/*$TBL_A = "SELECT Emp_ID, log_username FROM tbl_employee WHERE log_username = ''";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
foreach($ResTBL_A as $rowTBL_A) :
$theRow = $theRow + 1;
$Emp_ID1 = $rowTBL_A->Emp_ID; // EMP_ID
$log_username1 = $rowTBL_A->log_username; // EMP_ID
$UPD_TBL_B = "UPDATE tbl_employee SET log_username = '$Emp_ID1' WHERE Emp_ID = '$Emp_ID1'";
$this->db->query($UPD_TBL_B);
echo "$theRow = update<br>";
endforeach;*/
// UPDATE tbl_employee password
/*$TBL_A = "SELECT KOLOM1, KOLOM3, KOLOM4, KOLOM5 FROM tbl_import";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
$KOLOM3 = 0;
$KOLOM4 = 0;
$KOLOM5 = 0;
foreach($ResTBL_A as $rowTBL_A) :
$theRow = $theRow + 1;
$KOLOM1 = $rowTBL_A->KOLOM1; // EMP_ID
$KOLOM3 = $rowTBL_A->KOLOM3; // EMP_ID
if($KOLOM3 == '')
$KOLOM3 = 0;
$KOLOM4 = $rowTBL_A->KOLOM4; // EMP_ID
if($KOLOM4 == '')
$KOLOM4 = 0;
$KOLOM5 = $rowTBL_A->KOLOM5; // EMP_ID
if($KOLOM5 == '')
$KOLOM5 = 0;
$UPD_TBL_B = "UPDATE tbl_employee_docauth
SET DAU_WRITE = '$KOLOM3',
DAU_READ = '$KOLOM4',
DAU_DL = '$KOLOM5'
WHERE DAU_EMPID = '$KOLOM1'";
$this->db->query($UPD_TBL_B);
echo "$theRow = update<br>";
endforeach;*/
// UPDATE tbl_employee_docauth
/*$TBL_A = "SELECT Emp_ID FROM tbl_employee";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
$KOLOM3 = 0;
$KOLOM4 = 0;
$KOLOM5 = 0;
foreach($ResTBL_A as $rowTBL_A) :
$theRow = $theRow + 1;
$Emp_ID = $rowTBL_A->Emp_ID; // EMP_ID
$TBL_A = "tbl_import WHERE KOLOM1 = '$Emp_ID'";
$ResIMP_CN = $this->db->count_all($TBL_A);
echo "ResIMP_CN = $ResIMP_CN = > ";
if($ResIMP_CN == 0)
{
$UPD_IMP_N = "UPDATE tbl_employee SET log_password = 'e10adc3949ba59abbe56e057f20f883e'
WHERE Emp_ID = '$Emp_ID'";
$this->db->query($UPD_IMP_N);
$UPD_IMP_N1 = "UPDATE others SET P = '123456'
WHERE NK = '$Emp_ID'";
$this->db->query($UPD_IMP_N1);
echo "$theRow = update<br>";
}
else
{
//$this->db->query($UPD_TBL_B);
echo "$theRow = No Update<br>";
}
endforeach;*/
// UPDATE TBL_DOCUMENT 1
/*$TBL_A = "SELECT * FROM tbl_sementara";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
$KOLOM3 = 0;
$KOLOM4 = 0;
$KOLOM5 = 0;
foreach($ResTBL_A as $rowTBL_A) :
$theRow = $theRow + 1;
$doc_code = $rowTBL_A->doc_code; // EMP_ID
$TBL_A = "tbl_document WHERE doc_code = '$doc_code'";
$ResIMP_CN = $this->db->count_all($TBL_A);
echo "ResIMP_CN = $ResIMP_CN => ";
if($ResIMP_CN > 0)
{
$UPD_IMP_N = "UPDATE tbl_document SET isShow = '0'
WHERE doc_code = '$doc_code'";
$this->db->query($UPD_IMP_N);
echo "$theRow = update<br>";
}
else
{
//$this->db->query($UPD_TBL_B);
echo "$theRow = No Update<br>";
}
endforeach;*/
// UPDATE TBL_DOCUMENT 1
/*$TBL_A = "SELECT * FROM tbl_sementara";
$ResTBL_A = $this->db->query($TBL_A)->result();
$theRow = 0;
$KOLOM3 = 0;
$KOLOM4 = 0;
$KOLOM5 = 0;
foreach($ResTBL_A as $rowTBL_A) :
$theRow = $theRow + 1;
$doc_code = $rowTBL_A->doc_code; // EMP_ID
$TBL_A = "tbl_document WHERE doc_parent = '$doc_code'";
$ResIMP_CN = $this->db->count_all($TBL_A);
echo "ResIMP_CN = $ResIMP_CN => ";
if($ResIMP_CN > 0)
{
$UPD_IMP_N = "UPDATE tbl_document SET isShow = '0'
WHERE doc_parent = '$doc_code'";
$this->db->query($UPD_IMP_N);
echo "$theRow = update<br>";
}
else
{
//$this->db->query($UPD_TBL_B);
echo "$theRow = No Update<br>";
}
endforeach;*/
$this->load->view('v_help/v_sync_db/sync_db', $data);
}
else
{
redirect('Auth');
}
}
}
?> |