pedding = 2; // Bar Pedding $prb->brd_color = "#404040 #dfdfdf #dfdfdf #404040"; // Bar Border Color $prb->setFrame(); // set ProgressBar Frame $prb->frame['left'] = 400; // Frame position from left $prb->frame['top'] = 220; // Frame position from top $prb->addLabel('text','txt1','Please wait ...'); // add Text as Label 'txt1' and value 'Please wait' $prb->addLabel('percent','pct1'); // add Percent as Label 'pct1' $prb->addButton('btn1','Restart',$_SERVER['PHP_SELF'].'?restart=1'); // add Button as Label 'btn1' and action '?restart=1' global $HTTP_POST_FILES; if($_GET['actie'] == 'up' AND $_GET['refresh'] != true){ UpdatePossision("".$_GET['move_id']."",'UP',"tbl_producten_cat"); } elseif($_GET['actie'] == 'down' AND $_GET['refresh'] != true){ UpdatePossision("".$_GET['move_id']."",'DOWN',"tbl_producten_cat"); } $cat_id = GetCatId(); $type = $cat_id['type']; $getid = $cat_id['getid']; echo "
"; //javascript voor picturte upload define (VALID_ACCESS, true); require_once (DataGridClass); $grid = new DataGrid(DataGridTemplate); // if you use a different database $grid->db = new DB("".$crypt->decrypt(MYSQL_HOST)."", "".$crypt->decrypt(MYSQL_USER)."", "".$crypt->decrypt(MYSQL_PASSWORD)."", "".$crypt->decrypt(MYSQL_DB).""); $grid->TableName = "tbl_producten_cat"; if(!isset($type)){ //Begin Main echo ShowCats(); } elseif($type == '1'){ $grid->SelectSQL = "SELECT * FROM tbl_producten_cat WHERE cat_id = '$getid' AND type = '2' AND users_id = '".$crypt->decrypt($_SESSION['user_id'])."' ORDER BY possision"; $grid->AddTextBoxColumn("name", "Naam"); $grid->AddCheckBoxColumn("enabled", "Actief"); //$grid->AddComboColumn("type", "Categorie", array("2"=>"Sub1")); //$grid->AddComboColumn("cat_id", "Type", array("$getid"=>"$getid")); $grid->Columns[2]->CanEdit = false; //zet image uit hier /* $tpl = new Template(); $tpl->SetContent("
.jpg&maxsize=500&lightbox=true\" rel=\"lightbox[roadtrip]\" class=\"myclass\">.jpg&maxsize=50\"border=0>
"); $col = new DataGridCommandColumn("id", "Afbeelding", $tpl,"cmd_name", "my_column_clicked"); $grid->Columns[] = $col; */ $sql = 'SELECT `tbl_producten_filters`.id, `tbl_producten_filters`.name FROM `tbl_producten_filters` WHERE `tbl_producten_filters`.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result = mysql_query($sql); $total = @mysql_num_rows($result); //$row = mysql_fetch_array($result); $column = new DataGridComboColumn("filters_id", "Filter set",false); if($total != ''){ while ($row = mysql_fetch_array($result)) { $column->AddOption("".$row['id']."","".$row['name'].""); } } $grid->Columns[] = $column; $tpl = new Template(); $tpl->SetContent("&actie=up&id=".$_GET['id']."\" class=\"myclass\">\"Omhoog\" &actie=down&id=".$_GET['id']."\" class=\"myclass\">\"Omlaag\""); $col = new DataGridCommandColumn("id", "Positie", $tpl,"cmd_name", "my_column_clicked"); $grid->Columns[] = $col; $tpl = new Template(); $tpl->SetContent(" &type=2&id3=".$_GET['id']."\" class=\"DGTBButton\"> Open"); $col = new DataGridCommandColumn("id", "Actie", $tpl,"cmd_name", "my_column_clicked"); $grid->Columns[] = $col; $grid->OnUpdateCall ("on_update"); $grid->OnDeleteCall ("on_delete"); $grid->OnInsertCall ("datagrid_on_insert"); } elseif($type == '2'){ //$grid->SelectSQL = "SELECT * FROM tbl_cat WHERE type = 3 AND cat_id = $getid AND type = 3"; //$grid->SelectSQL = ""; if(isset($_POST)){ $prb->show(); // show the ProgressBar } if(isset($HTTP_POST_FILES)){ //haal de keys op if($array_keys = array_keys($HTTP_POST_FILES)){ $HTTP_POST_FILES['up_file']=array(); for($i = 0; count($array_keys) > $i; $i++){ //split zodat we het id hebben $Split_id = split('up_file_#',$array_keys[$i]); $id2 = $Split_id[1]; $HTTP_POST_FILES['up_file']['error'][$i]=$HTTP_POST_FILES['up_file_#'.$id2.'']['error']; // set new key $HTTP_POST_FILES['up_file']['name'][$i]=$HTTP_POST_FILES['up_file_#'.$id2.'']['name']; $HTTP_POST_FILES['up_file']['size'][$i]=$HTTP_POST_FILES['up_file_#'.$id2.'']['size']; $HTTP_POST_FILES['up_file']['tmp_name'][$i]=$HTTP_POST_FILES['up_file_#'.$id2.'']['tmp_name']; $HTTP_POST_FILES['up_file']['type'][$i]=$HTTP_POST_FILES['up_file_#'.$id2.'']['type']; //Set id $HTTP_POST_FILES['up_file']['id'][$i] = $id2; unset($HTTP_POST_FILES['up_file_#'.$id2.'']); // del old key } $test = array_merge($HTTP_POST_FILES_TEMP[0],$HTTP_POST_FILES_TEMP[1]); //if(isset($_GET['uploaddone'])){ include("".version."/admin/include/modules/producten/include/PictureUpload2.inc.php"); //} //$type = '2'; //echo "test"; } } //zet edit op true $edit = true; //load de lightbox scriptws echo LoadLightBox(); include("".version."/admin/include/modules/producten/include/Product_overview.inc.php"); $prb->setLabelValue('txt1','Completed'); //usleep(9000000); $prb->hide(); } //$grid->Columns[2]->Width = "100px"; if($type != '2'){ $grid->AllowSelect = false; $grid->CommandsRight = true; $grid->AllowDeleteSelected = false; //$grid->AllowCancelSort = true; $grid->AllowCancelSort = false; $grid->AllowInsert = $_SESSION['AllowInsert']; $grid->AllowPage = true; $grid->AllowDelete = $_SESSION['AllowDelete']; //$grid->AllowDelete = false; $grid->AllowEdit = $_SESSION['AllowEdit']; //$grid->Columns[2]->Width = "50px"; //$grid->Columns[8]->Width = "50px"; function on_update($id, $new_values, $cancel) { global $crypt; //kijk om wat voor type het gaat $cat_id = GetCatId(); $type = $cat_id['type']; $getid = $cat_id['getid']; //print_r($new_values); $cancel = true; // let the data grid to update rows by itself if(!isset($type)){ $query = "UPDATE tbl_producten_cat SET name='$new_values[0]', enabled='$new_values[1]', no_name_view='$new_values[2]' WHERE id='".$id."' AND users_id = '".$crypt->decrypt($_SESSION['user_id'])."'"; }elseif($type == 1){ $query = "UPDATE tbl_producten_cat SET name='$new_values[0]', enabled='$new_values[1]', filters_id='$new_values[2]' WHERE id='".$id."' AND users_id = '".$crypt->decrypt($_SESSION['user_id'])."'"; } $result = mysql_query($query) or die (mysql_error()); } function on_update_2($id, $new_values, $cancel) { /* //print_r($new_values); $cancel = true; // let the data grid to update rows by itself $query = "UPDATE tbl_producten_producten_cat SET name='$new_values[0]', enabled='$new_values[1]' WHERE id='".$id."'"; $result = mysql_query($query) or die (mysql_error()); $query = "UPDATE tbl_producten_products SET type_nummer='$new_values[2]', omschrijving='$new_values[3]', prijs='$new_values[4]' WHERE tbl_cat_id='".$id."'"; $result = mysql_query($query) or die (mysql_error()); */ } $grid->AllowSort = true; //$grid->sort_field = 2; $grid->ShowCaption = true; // listen for an event function datagrid_on_insert ($new_values, $cancel) { global $crypt; $cat_id = GetCatId(); $type = $cat_id['type'] +1; $getid = $cat_id['getid']; //print_r ($new_values); $cancel = true; // cancel it if you don't want DataGrid to insert by itself if(!isset($new_values[2])){ $new_values[2] = '0'; } $sql = 'INSERT INTO tbl_producten_cat (name,enabled,type,cat_id,filters_id,possision,users_id) VALUES (\''.$new_values[0].'\', \''.$new_values[1].'\', \''.$type.'\', \''.$getid.'\' , \''.$new_values[2].'\', \''.GetLastPossision("tbl_producten_cat").'\', \''.$crypt->decrypt($_SESSION['user_id']).'\')'; $result = mysql_query($sql) or die (mysql_error()); } function datagrid_on_insert_2 ($new_values, $cancel) { /* $cat_id = GetCatId(); //$cat_id = $_GET['id']; $type = '3'; $getid = $cat_id['getid']; //print_r ($new_values); $cancel = true; // cancel it if you don't want DataGrid to insert by itself $sql = 'INSERT INTO tbl_producten_cat (name,enabled,type,cat_id) VALUES (\''.$new_values[0].'\', \''.$new_values[1].'\', \''.$type.'\', \''.$getid.'\')'; $result = mysql_query($sql) or die (mysql_error()); $sql2 = 'SELECT tbl_producten_cat.id, tbl_producten_cat.name, tbl_producten_cat.enabled, tbl_producten_cat.type, tbl_producten_cat.cat_id FROM tbl_producten_cat order by id DESC'; $result = mysql_query($sql2); $total = @mysql_num_rows($result); $row = mysql_fetch_array($result); if($row['name'] == $new_values[0] AND $row['enabled'] == $new_values[1] AND $row['type'] == $type AND $row['cat_id'] == $getid){ $sql = 'INSERT INTO tbl_producten_products (tbl_cat_id, type_nummer, omschrijving, prijs) VALUES (\''.$row['id'].'\', \''.$new_values[2].'\', \''.$new_values[3].'\', \''.$new_values[4].'\')'; $result = mysql_query($sql) or die (mysql_error()); } */ } function on_delete($id, $cancel) { global $crypt; //echo "Deleting $id
"; $cancel = true; // let the data grid to update rows by itself //Kijk om wat voor een id het gaat //kijk welk type het is $type = GetType2($id); if($type == '1'){ /*type 1 Unlink alle afbeeldingen met de id's die we tegen komen Delete dan alles met het cat_id == id */ //kijk welke id's er allemaal onderhangen (type 2) $sql = 'SELECT `tbl_producten_cat`.id FROM `tbl_producten_cat` WHERE `tbl_producten_cat`.cat_id = \''.$id.'\' AND type=\'2\''; /*$sql = 'SELECT `tbl_producten_cat`.id, `tbl_producten_data`.`data`, `tbl_producten_filters_values`.value FROM `tbl_producten_data` INNER JOIN `tbl_producten_cat` ON (`tbl_producten_data`.tbl_cat_id = `tbl_producten_cat`.id) INNER JOIN `tbl_producten_filters_values` ON (`tbl_producten_data`.filters_values_id = `tbl_producten_filters_values`.id) INNER JOIN `tbl_producten_filters_types` ON (`tbl_producten_filters_values`.types_id = `tbl_producten_filters_types`.id) WHERE `tbl_producten_filters_types`.value = \'afbeelding\' AND `tbl_producten_cat`.id = \''.$id.'\' AND `tbl_producten_cat`.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; */ $result = mysql_query($sql); $total = @mysql_num_rows($result); //haal alle id's op while ($row = mysql_fetch_array($result)) { //unlink de afbeelding DeletePicture($row['id']); } //delete de type 2 met dit cat_id $query = 'DELETE FROM tbl_producten_cat WHERE cat_id=\''.$id.'\' AND type= \'2\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result4 = mysql_query($query) or die (mysql_error()); $query = 'DELETE FROM tbl_producten_cat WHERE id=\''.$id.'\' AND type= \'1\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result6 = mysql_query($query) or die (mysql_error()); } elseif($type == '2'){ /*type 2 unlink de afbeelding delete het id en alle type 3 cat_id die gelijk zijn aan het id */ //unlink de afbeelding DeletePicture($id); //delete de 1ste type2 $query = 'DELETE FROM tbl_producten_cat WHERE id=\''.$id.'\' AND type= \'2\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result = mysql_query($query) or die (mysql_error()); //kijk of er type3 onderliggen //zo ja //delete de onderliggende //kijk nog of er type3 onder dit id zitten zo ja delete deze dan $sql = 'SELECT tbl_producten_cat.id FROM tbl_producten_cat WHERE tbl_producten_cat.cat_id = \''.$id.'\' AND tbl_producten_cat.`type` = \'3\' AND `tbl_producten_cat`.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result2 = mysql_query($sql); $total = @mysql_num_rows($result2); if($total != ''){ //delete de type 3 die met cat_id = id $query = 'DELETE FROM tbl_producten_cat WHERE cat_producten_id=\''.$id.'\' AND type= \'3\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result3 = mysql_query($query) or die (mysql_error()); while ($row2 = mysql_fetch_array($result2)) { //delete ook de products $query = 'DELETE FROM tbl_producten_products WHERE tbl_producten_cat_id=\''.$row2['id'].'\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result4 = mysql_query($query) or die (mysql_error()); } } //niet meer nodig omdat we dit een stap hiervoor al doen //$query = 'DELETE FROM tbl_cat WHERE cat_id=\''.$id.'\' AND type= \'3\''; //$result = mysql_query($query) or die (mysql_error()); } elseif($type == '3'){ /*type 3 Doe gewoon een delete van het id + producten */ $query = 'DELETE FROM tbl_producten_cat WHERE id=\''.$id.'\' AND type= \'3\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; //$result = mysql_query($query) or die (mysql_error()); //delete ook de products $query = 'DELETE FROM tbl_producten_products WHERE tbl_cat_id=\''.$id.'\' AND tbl_producten_cat.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; //$result = mysql_query($query) or die (mysql_error()); } else { //hier zullen we niet komen omdat er altijd een id zal zijn... echo "Error Geen type!."; } } function on_delete_2($id, $cancel){ /* $cancel = true; // let the data grid to update rows by itself */ } // at last but not least render the grid //$grid->Render(); echo "
"; $_SESSION['delete'] = false; } function DeletePicture($id){ Global $crypt; $sql = 'SELECT `tbl_producten_cat`.id, `tbl_producten_data`.`data`, `tbl_producten_filters_values`.value FROM `tbl_producten_data` INNER JOIN `tbl_producten_cat` ON (`tbl_producten_data`.tbl_cat_id = `tbl_producten_cat`.id) INNER JOIN `tbl_producten_filters_values` ON (`tbl_producten_data`.filters_values_id = `tbl_producten_filters_values`.id) INNER JOIN `tbl_producten_filters_types` ON (`tbl_producten_filters_values`.types_id = `tbl_producten_filters_types`.id) WHERE `tbl_producten_filters_types`.value = \'afbeelding\' AND `tbl_producten_cat`.id = \''.$id.'\' AND `tbl_producten_cat`.users_id = \''.$crypt->decrypt($_SESSION['user_id']).'\''; $result = mysql_query($sql); $total = @mysql_num_rows($result); if($total != ''){ while ($row = mysql_fetch_array($result)) { $path = "".UserFilesPath."/".$_SESSION['username']."/Uploads/".$row['data'].".jpg"; $path2 = "".UserFilesPath."/".$_SESSION['username']."/tmp/".$row['data']."_thumb.jpg"; if (@file_exists($path)) { @unlink($path); } if (@file_exists($path2)) { @unlink($path2); } } } } ?>