{"action":"created","comment":{"url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/comments/74544748","id":74544748,"diff_hunk":"@@ -143,18 +143,50 @@\n   foreach ($tilausrivit as $rivitunnus => $data) {\n     $tuoteno = $data['tuoteno'];\n     $kpl     = $data['kpl'];\n+    $uusi_id = 0;\n \n     $query = \"SELECT *\n               FROM tilausrivi\n               WHERE yhtio = '{$yhtio}'\n+              AND tuoteno = '{$tuoteno}'\n               AND tunnus = '{$rivitunnus}'\";\n     $tilausrivires = pupe_query($query);\n+\n+    if (mysql_num_rows($tilausrivires) != 1) {\n+       pupesoft_log('logmaster_inbound_delivery_confirmation', \"Tilausrivi� ei l�ydy rivitunnuksella {$rivitunnus} ja tuotenumerolla {$tuoteno}.\");\n+       continue;\n+    }\n+\n     $tilausrivirow = mysql_fetch_assoc($tilausrivires);\n \n     if ($kpl > $tilausrivirow['varattu']) {\n       pupesoft_log('logmaster_inbound_delivery_confirmation', \"Sanoman kpl suurempi kuin tietokannassa. Rivitunnus {$rivitunnus}, sanoman kpl {$kpl}, tietokannan varattu {$tilausrivirow['varattu']}.\");\n     }\n \n+    # splitataan rivi\n+    if ($kpl < $tilausrivirow['varattu']) {\n+      $erotus = ($tilausrivirow['varattu'] - $kpl);\n+      $uusi_id = (int) splittaa_tilausrivi($rivitunnus, $kpl);\n+\n+      if ($uusi_id != 0) {\n+        # J�tet��n alkuper�iselle tilausriville j�ljelle j��v� kappalem��r�\n+        # Halutaan ett� uusi splitattu rivi menee varastoon\n+        $query = \"UPDATE tilausrivi SET\n+                  varattu   = '{$erotus}'\n+                  WHERE yhtio     = '{$yhtio}'\n+                  AND tyyppi      = 'O'\n+                  AND kpl         = 0\n+                  AND tuoteno     = '{$tuoteno}'\n+                  AND tunnus      = '{$rivitunnus}'\";\n+        $updres = pupe_query($query);\n+\n+        pupesoft_log('logmaster_inbound_delivery_confirmation', \"Tilausrivi {$rivitunnus} splitattiin. Uusi k�ytetty tunnus on {$uusi_id}.\");","path":"rajapinnat/logmaster/inbound_delivery_confirmation.php","position":null,"original_position":41,"commit_id":"221aa5472f7e1a47b1e8bd537f869f4cf79d76f9","original_commit_id":"221aa5472f7e1a47b1e8bd537f869f4cf79d76f9","user":{"login":"jonikanerva","id":679717,"avatar_url":"https://avatars.githubusercontent.com/u/679717?v=3","gravatar_id":"","url":"https://api.github.com/users/jonikanerva","html_url":"https://github.com/jonikanerva","followers_url":"https://api.github.com/users/jonikanerva/followers","following_url":"https://api.github.com/users/jonikanerva/following{/other_user}","gists_url":"https://api.github.com/users/jonikanerva/gists{/gist_id}","starred_url":"https://api.github.com/users/jonikanerva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonikanerva/subscriptions","organizations_url":"https://api.github.com/users/jonikanerva/orgs","repos_url":"https://api.github.com/users/jonikanerva/repos","events_url":"https://api.github.com/users/jonikanerva/events{/privacy}","received_events_url":"https://api.github.com/users/jonikanerva/received_events","type":"User","site_admin":false},"body":"Tämä on vähän epäselvä message, ei ehkä kerro asiakkaalle mitään. Tässä pitäisi olla jotain; saavutettiin vähemmän tuotteitta kun tilauksella oli. tilauksella 10, saavutettiin 3, saavuttamatta vielä 7.  tms.","created_at":"2016-08-12T06:02:18Z","updated_at":"2016-08-12T06:02:18Z","html_url":"https://github.com/devlab-oy/pupesoft/pull/3292#discussion_r74544748","pull_request_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292","_links":{"self":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/comments/74544748"},"html":{"href":"https://github.com/devlab-oy/pupesoft/pull/3292#discussion_r74544748"},"pull_request":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292"}}},"pull_request":{"url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292","id":80955759,"html_url":"https://github.com/devlab-oy/pupesoft/pull/3292","diff_url":"https://github.com/devlab-oy/pupesoft/pull/3292.diff","patch_url":"https://github.com/devlab-oy/pupesoft/pull/3292.patch","issue_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/3292","number":3292,"state":"open","locked":false,"title":"Logmaster: Saapumisen osatoimitus","user":{"login":"samiluukkonen","id":797650,"avatar_url":"https://avatars.githubusercontent.com/u/797650?v=3","gravatar_id":"","url":"https://api.github.com/users/samiluukkonen","html_url":"https://github.com/samiluukkonen","followers_url":"https://api.github.com/users/samiluukkonen/followers","following_url":"https://api.github.com/users/samiluukkonen/following{/other_user}","gists_url":"https://api.github.com/users/samiluukkonen/gists{/gist_id}","starred_url":"https://api.github.com/users/samiluukkonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samiluukkonen/subscriptions","organizations_url":"https://api.github.com/users/samiluukkonen/orgs","repos_url":"https://api.github.com/users/samiluukkonen/repos","events_url":"https://api.github.com/users/samiluukkonen/events{/privacy}","received_events_url":"https://api.github.com/users/samiluukkonen/received_events","type":"User","site_admin":false},"body":"Sallitaan saman saapumisen sisäänluku moneen kertaan","created_at":"2016-08-11T13:18:57Z","updated_at":"2016-08-12T06:02:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a035a3dba34c7714bd3340990a3798e3517e029","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292/commits","review_comments_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292/comments","review_comment_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/3292/comments","statuses_url":"https://api.github.com/repos/devlab-oy/pupesoft/statuses/221aa5472f7e1a47b1e8bd537f869f4cf79d76f9","head":{"label":"devlab-oy:sami/logmaster_inbound_partial","ref":"sami/logmaster_inbound_partial","sha":"221aa5472f7e1a47b1e8bd537f869f4cf79d76f9","user":{"login":"devlab-oy","id":679728,"avatar_url":"https://avatars.githubusercontent.com/u/679728?v=3","gravatar_id":"","url":"https://api.github.com/users/devlab-oy","html_url":"https://github.com/devlab-oy","followers_url":"https://api.github.com/users/devlab-oy/followers","following_url":"https://api.github.com/users/devlab-oy/following{/other_user}","gists_url":"https://api.github.com/users/devlab-oy/gists{/gist_id}","starred_url":"https://api.github.com/users/devlab-oy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlab-oy/subscriptions","organizations_url":"https://api.github.com/users/devlab-oy/orgs","repos_url":"https://api.github.com/users/devlab-oy/repos","events_url":"https://api.github.com/users/devlab-oy/events{/privacy}","received_events_url":"https://api.github.com/users/devlab-oy/received_events","type":"Organization","site_admin":false},"repo":{"id":1602660,"name":"pupesoft","full_name":"devlab-oy/pupesoft","owner":{"login":"devlab-oy","id":679728,"avatar_url":"https://avatars.githubusercontent.com/u/679728?v=3","gravatar_id":"","url":"https://api.github.com/users/devlab-oy","html_url":"https://github.com/devlab-oy","followers_url":"https://api.github.com/users/devlab-oy/followers","following_url":"https://api.github.com/users/devlab-oy/following{/other_user}","gists_url":"https://api.github.com/users/devlab-oy/gists{/gist_id}","starred_url":"https://api.github.com/users/devlab-oy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlab-oy/subscriptions","organizations_url":"https://api.github.com/users/devlab-oy/orgs","repos_url":"https://api.github.com/users/devlab-oy/repos","events_url":"https://api.github.com/users/devlab-oy/events{/privacy}","received_events_url":"https://api.github.com/users/devlab-oy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/devlab-oy/pupesoft","description":"Suomalainen, avoimen lähdekoodin, toiminnanohjausjärjestelmä PK-yrityksille.","fork":false,"url":"https://api.github.com/repos/devlab-oy/pupesoft","forks_url":"https://api.github.com/repos/devlab-oy/pupesoft/forks","keys_url":"https://api.github.com/repos/devlab-oy/pupesoft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devlab-oy/pupesoft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devlab-oy/pupesoft/teams","hooks_url":"https://api.github.com/repos/devlab-oy/pupesoft/hooks","issue_events_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/events{/number}","events_url":"https://api.github.com/repos/devlab-oy/pupesoft/events","assignees_url":"https://api.github.com/repos/devlab-oy/pupesoft/assignees{/user}","branches_url":"https://api.github.com/repos/devlab-oy/pupesoft/branches{/branch}","tags_url":"https://api.github.com/repos/devlab-oy/pupesoft/tags","blobs_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/refs{/sha}","trees_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devlab-oy/pupesoft/statuses/{sha}","languages_url":"https://api.github.com/repos/devlab-oy/pupesoft/languages","stargazers_url":"https://api.github.com/repos/devlab-oy/pupesoft/stargazers","contributors_url":"https://api.github.com/repos/devlab-oy/pupesoft/contributors","subscribers_url":"https://api.github.com/repos/devlab-oy/pupesoft/subscribers","subscription_url":"https://api.github.com/repos/devlab-oy/pupesoft/subscription","commits_url":"https://api.github.com/repos/devlab-oy/pupesoft/commits{/sha}","git_commits_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/commits{/sha}","comments_url":"https://api.github.com/repos/devlab-oy/pupesoft/comments{/number}","issue_comment_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/comments{/number}","contents_url":"https://api.github.com/repos/devlab-oy/pupesoft/contents/{+path}","compare_url":"https://api.github.com/repos/devlab-oy/pupesoft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devlab-oy/pupesoft/merges","archive_url":"https://api.github.com/repos/devlab-oy/pupesoft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devlab-oy/pupesoft/downloads","issues_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues{/number}","pulls_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls{/number}","milestones_url":"https://api.github.com/repos/devlab-oy/pupesoft/milestones{/number}","notifications_url":"https://api.github.com/repos/devlab-oy/pupesoft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devlab-oy/pupesoft/labels{/name}","releases_url":"https://api.github.com/repos/devlab-oy/pupesoft/releases{/id}","deployments_url":"https://api.github.com/repos/devlab-oy/pupesoft/deployments","created_at":"2011-04-12T05:26:18Z","updated_at":"2016-08-04T23:16:11Z","pushed_at":"2016-08-12T05:54:22Z","git_url":"git://github.com/devlab-oy/pupesoft.git","ssh_url":"git@github.com:devlab-oy/pupesoft.git","clone_url":"https://github.com/devlab-oy/pupesoft.git","svn_url":"https://github.com/devlab-oy/pupesoft","homepage":"www.devlab.fi","size":111516,"stargazers_count":29,"watchers_count":29,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":28,"forks":17,"open_issues":28,"watchers":29,"default_branch":"master"}},"base":{"label":"devlab-oy:master","ref":"master","sha":"7c49ececdb12181b2ff79510656fb2f2ef997b5a","user":{"login":"devlab-oy","id":679728,"avatar_url":"https://avatars.githubusercontent.com/u/679728?v=3","gravatar_id":"","url":"https://api.github.com/users/devlab-oy","html_url":"https://github.com/devlab-oy","followers_url":"https://api.github.com/users/devlab-oy/followers","following_url":"https://api.github.com/users/devlab-oy/following{/other_user}","gists_url":"https://api.github.com/users/devlab-oy/gists{/gist_id}","starred_url":"https://api.github.com/users/devlab-oy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlab-oy/subscriptions","organizations_url":"https://api.github.com/users/devlab-oy/orgs","repos_url":"https://api.github.com/users/devlab-oy/repos","events_url":"https://api.github.com/users/devlab-oy/events{/privacy}","received_events_url":"https://api.github.com/users/devlab-oy/received_events","type":"Organization","site_admin":false},"repo":{"id":1602660,"name":"pupesoft","full_name":"devlab-oy/pupesoft","owner":{"login":"devlab-oy","id":679728,"avatar_url":"https://avatars.githubusercontent.com/u/679728?v=3","gravatar_id":"","url":"https://api.github.com/users/devlab-oy","html_url":"https://github.com/devlab-oy","followers_url":"https://api.github.com/users/devlab-oy/followers","following_url":"https://api.github.com/users/devlab-oy/following{/other_user}","gists_url":"https://api.github.com/users/devlab-oy/gists{/gist_id}","starred_url":"https://api.github.com/users/devlab-oy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlab-oy/subscriptions","organizations_url":"https://api.github.com/users/devlab-oy/orgs","repos_url":"https://api.github.com/users/devlab-oy/repos","events_url":"https://api.github.com/users/devlab-oy/events{/privacy}","received_events_url":"https://api.github.com/users/devlab-oy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/devlab-oy/pupesoft","description":"Suomalainen, avoimen lähdekoodin, toiminnanohjausjärjestelmä PK-yrityksille.","fork":false,"url":"https://api.github.com/repos/devlab-oy/pupesoft","forks_url":"https://api.github.com/repos/devlab-oy/pupesoft/forks","keys_url":"https://api.github.com/repos/devlab-oy/pupesoft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devlab-oy/pupesoft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devlab-oy/pupesoft/teams","hooks_url":"https://api.github.com/repos/devlab-oy/pupesoft/hooks","issue_events_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/events{/number}","events_url":"https://api.github.com/repos/devlab-oy/pupesoft/events","assignees_url":"https://api.github.com/repos/devlab-oy/pupesoft/assignees{/user}","branches_url":"https://api.github.com/repos/devlab-oy/pupesoft/branches{/branch}","tags_url":"https://api.github.com/repos/devlab-oy/pupesoft/tags","blobs_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/refs{/sha}","trees_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devlab-oy/pupesoft/statuses/{sha}","languages_url":"https://api.github.com/repos/devlab-oy/pupesoft/languages","stargazers_url":"https://api.github.com/repos/devlab-oy/pupesoft/stargazers","contributors_url":"https://api.github.com/repos/devlab-oy/pupesoft/contributors","subscribers_url":"https://api.github.com/repos/devlab-oy/pupesoft/subscribers","subscription_url":"https://api.github.com/repos/devlab-oy/pupesoft/subscription","commits_url":"https://api.github.com/repos/devlab-oy/pupesoft/commits{/sha}","git_commits_url":"https://api.github.com/repos/devlab-oy/pupesoft/git/commits{/sha}","comments_url":"https://api.github.com/repos/devlab-oy/pupesoft/comments{/number}","issue_comment_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues/comments{/number}","contents_url":"https://api.github.com/repos/devlab-oy/pupesoft/contents/{+path}","compare_url":"https://api.github.com/repos/devlab-oy/pupesoft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devlab-oy/pupesoft/merges","archive_url":"https://api.github.com/repos/devlab-oy/pupesoft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devlab-oy/pupesoft/downloads","issues_url":"https://api.github.com/repos/devlab-oy/pupesoft/issues{/number}","pulls_url":"https://api.github.com/repos/devlab-oy/pupesoft/pulls{/number}","milestones_url":"https://api.github.com/repos/devlab-oy/pupesoft/milestones{/number}","notifications_url":"https://api.github.com/repos/devlab-oy/pupesoft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devlab-oy/pupesoft/labels{/name}","releases_url":"https://api.github.com/repos/devlab-oy/pupesoft/releases{/id}","deployments_url":"https://api.github.com/repos/devlab-oy/pupesoft/deployments","created_at":"2011-04-12T05:26:18Z","updated_at":"2016-08-04T23:16:11Z","pushed_at":"2016-08-12T05:54:22Z","git_url":"git://github.com/devlab-oy/pupesoft.git","ssh_url":"git@github.com:devlab-oy/pupesoft.git","clone_url":"https://github.com/devlab-oy/pupesoft.git","svn_url":"https://github.com/devlab-oy/pupesoft","homepage":"www.devlab.fi","size":111516,"stargazers_count":29,"watchers_count":29,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":28,"forks":17,"open_issues":28,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292"},"html":{"href":"https://github.com/devlab-oy/pupesoft/pull/3292"},"issue":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/issues/3292"},"comments":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/issues/3292/comments"},"review_comments":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292/comments"},"review_comment":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/pulls/3292/commits"},"statuses":{"href":"https://api.github.com/repos/devlab-oy/pupesoft/statuses/221aa5472f7e1a47b1e8bd537f869f4cf79d76f9"}}}}
{"actor":{"display_login":"jonikanerva"}}