diff --git a/design/atomic/html/repairs_post.tpl b/design/atomic/html/repairs_post.tpl index fa05e26..d5ea46a 100644 --- a/design/atomic/html/repairs_post.tpl +++ b/design/atomic/html/repairs_post.tpl @@ -2,7 +2,7 @@
diff --git a/repairs.sql b/repairs.sql index ccbf177..ef784f2 100644 --- a/repairs.sql +++ b/repairs.sql @@ -2,7 +2,7 @@ create table s_repair_photo ( id int auto_increment primary key, - action_id int default 0 not null, + repair_id int default 0 not null, img varchar(100) default '' not null, position int default 0 not null ) diff --git a/simpla/RepairsPostAdmin.php b/simpla/RepairsPostAdmin.php index 22b67bb..752b8f0 100644 --- a/simpla/RepairsPostAdmin.php +++ b/simpla/RepairsPostAdmin.php @@ -80,7 +80,7 @@ class RepairsPostAdmin extends Simpla $this->design->assign('post', $post); - $this->db->query("SELECT * FROM __repairs_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC"); + $this->db->query("SELECT * FROM __repair_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC"); $photos = $this->db->results(); foreach($photos as $ph) $ph->img = Img::get('files/post/' . $ph->img, array('width'=>120, 'height'=>120)); $this->design->assign('repair_photos', $photos); diff --git a/simpla/ajax/file_repair.php b/simpla/ajax/file_repair.php new file mode 100644 index 0000000..c42c400 --- /dev/null +++ b/simpla/ajax/file_repair.php @@ -0,0 +1,38 @@ +db->query("DELETE FROM __repair_photo WHERE id=" . (int)$_POST['id']); + die; +} + +if(isset($_POST['action']) && $_POST['action'] == 'reorder'){ + foreach($_POST['ids'] as $pos => $id){ + $simpla->db->query("UPDATE __repair_photo SET position='$pos' WHERE id='" . (int)$id ."' " ); + } + die; +} + + + +$ext = mb_strtolower(substr(strrchr($_FILES['file']['name'], '.'), 1), 'UTF-8'); +$name = $_POST['article_id'] . '_' . md5( uniqid( $_POST['article_id'] . rand(1, 10000), true) ) . '.' . $ext; + + + +move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/files/post/' . $name); + + + +$simpla->db->query("INSERT INTO __repair_photo SET repair_id='" . (int)$_POST['article_id'] ."', img='$name', position=999 " ); + +echo $simpla->db->insert_id(); + +//print_r($_POST); print_r($_FILES); +//echo 3; + +//echo json_encode(array('id'=>44, 'img'=>'test')); \ No newline at end of file diff --git a/simpla/design/html/repair_photo.tpl b/simpla/design/html/repair_photo.tpl index 099af1d..f8b92ec 100644 --- a/simpla/design/html/repair_photo.tpl +++ b/simpla/design/html/repair_photo.tpl @@ -38,7 +38,7 @@ $(function(){ var sxFile = new sxFormFile(); {/literal} - sxFile.init({$post->id}, '/simpla/ajax/file_action.php'); + sxFile.init({$post->id}, '/simpla/ajax/file_repair.php'); {literal} }) diff --git a/simpla/design/html/repairs_post.tpl b/simpla/design/html/repairs_post.tpl index fc827de..26bd059 100644 --- a/simpla/design/html/repairs_post.tpl +++ b/simpla/design/html/repairs_post.tpl @@ -120,7 +120,7 @@ function translit(str)